DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24082>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24082 bug in InstanceKeyDataSourceFactory Summary: bug in InstanceKeyDataSourceFactory Product: Commons Version: 1.1 Final Platform: All OS/Version: All Status: NEW Severity: Blocker Priority: Other Component: Dbcp AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I took DBCP 1.1 for a spin today (I was going to try CVS today, but for the release - if only it had been earlier! :) There's a fatal bug in InstanceKeyDataSourceFactory that means you can't instantiate more than one factory. I'm using this via Tomcat 4. There is this function that is called first: InstanceKeyDataSourceFactory.getObjectInstance() ... String key = null; if (name != null) { key = name.toString(); obj = instanceMap.get(key); } if (obj == null) { InstanceKeyDataSource ds = getNewInstance(ref); setCommonProperties(ref, ds); obj = ds; if (key != null) { instanceMap.put(key, ds); } } So, key = something like "myDb", which is put into instanceMap. But then there is: synchronized static String registerNewInstance(InstanceKeyDataSource ds) { int max = 0; Iterator i = instanceMap.keySet().iterator(); while (i.hasNext()) { Object obj = i.next(); if (obj instanceof String) { max = Math.max(max, Integer.parseInt((String)obj)); } } String instanceKey = String.valueOf(max + 1); // put a placeholder here for now, so other instances will not // take our key. we will replace with a pool when ready. instanceMap.put(instanceKey, ds); return instanceKey; } The Math.max line throws a NumberFormatException, because the key is assumed to be an int, but it is "myDb". What is the way to resolve this? My feeling is that it just doesn't set max if the key is not a number, so the first one gets "0", etc. Is that ok? I've done this and it seems to work, so I'll attach that quick fix as a patch. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
