We're updating the issue view to help you get more done. 

Reading values from olfs.xml file is fragile

Description

Please fix this ASAP since it's very hard to debug.

I used the olfs.xml file to set the log file path and default ping values, however, it failed even though the code clearly was reading the values from the log file. I found that the code to extract values using the XPaths for the HyraxLogfilePath and DefaultPing elements is very easy to break. If the XML file is formatted like this:

1 2 3 4 5 <LogReporter> <HyraxLogfilePath>/Users/jimg/src/opendap/hyrax_git/apache-tomcat-7.0.57/webapps/opendap/WE\ B-INF/conf/logs/AnonymousAccess.log</HyraxLogfilePath> <DefaultPing>1800</DefaultPing> </LogReporter>

if works great. However, if it is formatted like this:

1 2 3 4 5 6 7 8 9 <LogReporter> <HyraxLogfilePath> /Users/jimg/src/opendap/hyrax_git/apache-tomcat-7.0.57/webapps/opendap/WE\ B-INF/conf/logs/AnonymousAccess.log </HyraxLogfilePath> <DefaultPing> 1800 </DefaultPing> </LogReporter>

massive fail...

The problem is that the the latter has two CR characters and spaces at the begining and end of each value. Here's what it said in the log when the latter formatting was used:

1 2 3 4 5 6 7 8 9 10 2016-07-01 07:16:20.095 DEBUG 2914 --- [http-bio-8080-exec-8] o.s.w.f.CommonsRequestLoggingFilter : After request [uri=/reporter/defaultPing?null;client=0:0:0:0:0:0:0:1] 2016-07-01 07:16:20.096 ERROR 2914 --- [http-bio-8080-exec-8] o.s.boot.context.web.ErrorPageFilter : Forwarding to error page from request [/defaultPing] due to exception [For input string: " 1800 "] java.lang.NumberFormatException: For input string: " 1800 " at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.7.0_72] at java.lang.Long.parseLong(Long.java:430) ~[na:1.7.0_72]

Environment

None

Status

Assignee

Eduard Grinchenko

Reporter

James Gallagher

Labels

None

Story Points

None

Priority

Highest