Java fails to read numeric opensrf config values

Bug #1090463 reported by Bill Erickson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSRF
Fix Released
Undecided
Unassigned
2.1
Fix Committed
Undecided
Unassigned

Bug Description

Recent changes to the Java JSON library are causing problems with the OpenSRF Java configuration file parsing.

See working => user/berick/java-config-parse-repairs

From the commit:
=====

Java config parsing, in particular getString and getInt, no longer fail when encountering a number value in the internl JSON->Map object.

Java does not allow the following cast:

String s = (String) someNumber;

Instead, rely on the object's toString() which is safe and guaranteed to exist.
====

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Yeah, I have that commit, too, and still Java doesn't work for me.

Changed in opensrf:
status: New → Triaged
Revision history for this message
Jason Stephenson (jstephenson) wrote :

Here's what I get:

{"config":{"shared":{"log_protect":{"match_string":["open-ils.auth.authenticate.verify","open-ils.auth.authenticate.complete","open-ils.auth_proxy.login","open-ils.actor.user.password","open-ils.actor.user.username","open-ils.actor.user.email","open-ils.actor.patron.update","open-ils.cstore.direct.actor.user.create","open-ils.cstore.direct.actor.user.update","open-ils.cstore.direct.actor.user.delete"]}},"opensrf":{"port":5222,"passwd":"PASSWD","loglevel":3,"username":"opensrf","domain":"private.localhost","routers":{"router":[{"services":{"service":["opensrf.math","open-ils.actor","open-ils.acq","open-ils.auth","open-ils.auth_proxy","open-ils.booking","open-ils.cat","open-ils.circ","open-ils.collections","open-ils.fielder","open-ils.pcrud","open-ils.permacrud","open-ils.reporter","open-ils.resolver","open-ils.search","open-ils.supercat","open-ils.vandelay","open-ils.serial"]},"name":"router","domain":"public.localhost"},{"name":"router","domain":"private.localhost"}]},"settings_config":"/openils/conf/opensrf.xml","logfile":"/openils/var/log/osrfsys.log","router_name":"router"},"gateway":{"port":5222,"passwd":"PASSWD","loglevel":3,"username":"opensrf","services":{"service":["opensrf.math","opensrf.dbmath","open-ils.cat","open-ils.search","open-ils.circ","open-ils.actor","open-ils.auth","open-ils.auth_proxy","open-ils.collections","open-ils.reporter"]},"client":true,"domain":"public.localhost","logfile":"/openils/var/log/gateway.log","router_name":"router"},"routers":{"router":[{"loglevel":2,"transport":{"unixpath":"/openils/var/sock/unix_sock","port":5222,"username":"router","resource":"router","max_reconnect_attempts":5,"server":"public.localhost","connect_timeout":10,"password":"PASSWD"},"trusted_domains":{"client":["private.localhost","public.localhost"],"server":"private.localhost"},"logfile":"/openils/var/log/router-public.log"},{"loglevel":2,"transport":{"port":5222,"username":"router","resource":"router","max_reconnect_attempts":5,"server":"private.localhost","connect_timeout":10,"password":"PASSWD"},"trusted_domains":{"client":"private.localhost","server":"private.localhost"},"logfile":"/openils/var/log/router-private.log"}]}}}
org.opensrf.MethodException: java.lang.NullPointerException
 at org.opensrf.ClientSession.atomicRequest(ClientSession.java:171)
 at org.open_ils.util.Utils.login(Utils.java:30)
 at Login.main(Login.java:29)
Caused by: java.lang.NullPointerException
 at org.opensrf.Session.send(Session.java:55)
 at org.opensrf.Request.send(Request.java:62)
 at org.opensrf.ClientSession.request(ClientSession.java:107)
 at org.opensrf.ClientSession.request(ClientSession.java:89)
 at org.opensrf.ClientSession.atomicRequest(ClientSession.java:164)
 ... 2 more

I've obfuscated the password in the error above, of course. Similar Perl code works just fine.

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Here's what I'm using to test.

Let me know if there's anything wrong with my Java code.

Revision history for this message
Bill Erickson (berick) wrote :

Thanks Jason. The test file is failing because it's not connecting to the opensrf network (Sys.bootstrapClient). I suggest trying the test code in the repository.

http://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/src/java/org/open_ils/test/TestLogin.java

% CLASSPATH=$STUFF java org.open_ils.test.TestLogin /openils/conf/opensrf_core.xml admin PASSWORD

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Thanks!

It's working for me, now.

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Pushed a signoff to

http://git.evergreen-ils.org/?p=working/OpenSRF.git;a=shortlog;h=refs/heads/user/dyrcona/java-config-parse-repairs

I would have pushed to the main repository, but I don't actually have that configured as a remote, and I'm feeling a little lazy. :)

tags: added: signedoff
Changed in opensrf:
status: Triaged → Confirmed
Revision history for this message
Dan Scott (denials) wrote :

Committed to master and rel_2_1. Thanks to both of you!

Changed in opensrf:
milestone: none → 2.1.3
status: Confirmed → Fix Committed
Galen Charlton (gmc)
Changed in opensrf:
milestone: 2.1.3 → 2.2.0-alpha
Galen Charlton (gmc)
Changed in opensrf:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.