Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resource.java should check if AtomEntry updated value is a valid format or handle Value.toDate throwing a NumberFormatException. #131

Closed
TeresaP opened this issue Jan 28, 2019 · 3 comments

Comments

@TeresaP
Copy link

TeresaP commented Jan 28, 2019

if (value == null) {

If there's a problem with the value of entry in https://github.com/splunk/splunk-sdk-java/blob/master/splunk/com/splunk/Job.java#L936, where the AtomEntry updated value is an empty string, Value.toDate(...) will throw a java.lang.NumberFormatException.

java.lang.NumberFormatException: empty String

	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
	at java.lang.Double.parseDouble(Double.java:538)
	at java.text.DigitList.getDouble(DigitList.java:169)
	at java.text.DecimalFormat.parse(DecimalFormat.java:2056)
	at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1869)
	at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1514)
	at java.text.DateFormat.parse(DateFormat.java:364)
	at com.splunk.Value.toDate(Value.java:109)
	at com.splunk.Resource.load(Resource.java:166)
	at com.splunk.Entity.load(Entity.java:356)
	at com.splunk.Job.refresh(Job.java:940)
	at com.splunk.Job.isDone(Job.java:806)

Could this be related to #108?

Edit: I came across this today, too. In addition to checking for an empty string, this code should check if the format is valid:

java.lang.NumberFormatException: For input string: "970197.4E4970197E4"
	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
	at java.lang.Double.parseDouble(Double.java:538)
	at java.text.DigitList.getDouble(DigitList.java:169)
	at java.text.DecimalFormat.parse(DecimalFormat.java:2056)
	at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1869)
	at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1514)
	at java.text.DateFormat.parse(DateFormat.java:364)
	at com.splunk.Value.toDate(Value.java:109)
	at com.splunk.Resource.load(Resource.java:166)
	at com.splunk.Entity.load(Entity.java:356)
	at com.splunk.Entity.refresh(Entity.java:394)
	at com.splunk.Entity.refresh(Entity.java:24)
	at com.splunk.Resource.validate(Resource.java:186)
	at com.splunk.Entity.validate(Entity.java:462)
	at com.splunk.Entity.getContent(Entity.java:157)
	at com.splunk.Entity.getString(Entity.java:279)
	at com.splunk.ServiceInfo.getVersion(ServiceInfo.java:155)
	at com.splunk.Service.login(Service.java:1130)
	at com.splunk.Service.login(Service.java:1103)
	at com.splunk.Service.connect(Service.java:189)
@TeresaP TeresaP changed the title Resource.java should check if entry.updated is an empty string or handle Value.toDate throwing a NumberFormatException. Resource.java should check if AtomEntry updated value is an empty string or handle Value.toDate throwing a NumberFormatException. Jan 28, 2019
@TeresaP TeresaP changed the title Resource.java should check if AtomEntry updated value is an empty string or handle Value.toDate throwing a NumberFormatException. Resource.java should check if AtomEntry updated value is a valid format or handle Value.toDate throwing a NumberFormatException. Feb 13, 2019
@TeresaP
Copy link
Author

TeresaP commented Mar 5, 2019

@shakeelmohamed Is there any other information needed for this bug?

@shakeelmohamed
Copy link
Contributor

@TeresaP sorry for the delay here. We're open to a PR of you're interested in making the change, unfortunately we don't have the resources to spend time on this at the moment

@TeresaP
Copy link
Author

TeresaP commented Jun 21, 2019

Looks like this should be fixed by #109 and was a duplicate of #108

@TeresaP TeresaP closed this as completed Jun 21, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants