[c3p0-users] [PATCH] com/mchange/v2/lang/VersionUtils.extractVersionNumberArray
Status: Beta
Brought to you by:
swaldman
From: Dirk.Weigenand <Dir...@gm...> - 2007-05-22 14:23:53
|
Hi, the method in the subject has a problem with extra version info after the java version for example in the java 1.6.0_02 release: [2007-05-20 14:43:03,583] WARN com.mchange.v2.lang.VersionUtils java.versi= on ''1.6.0_02-ea'' could not be parsed. Defaulting to JDK 1.1. I propose the following change to the method: diff -r -u c3p0-0.9.1.1.src/src/classes/com/mchange/v2/lang/VersionUtils.ja= va c3p0-0.9.1.1.src-changed/src/classes/com/mchange/v2/lang/VersionUtils.ja= va =2D-- c3p0-0.9.1.1.src/src/classes/com/mchange/v2/lang/VersionUtils.java 20= 07-03-15 05:32:30.000000000 +0000 +++ c3p0-0.9.1.1.src-changed/src/classes/com/mchange/v2/lang/VersionUtils.j= ava 2007-05-22 13:48:15.000000000 +0000 @@ -140,7 +140,14 @@ public static int[] extractVersionNumberArray(String versionString, St= ring delims) throws NumberFormatException { =2D String[] intStrs =3D StringTokenizerUtils.tokenizeToArray( versionStrin= g, delims, false ); + int idx =3D versionString.indexOf('-'); + String version =3D versionString; +=20=20=20=20 + if (idx > -1) { + version =3D versionString.substring(0, idx); + } + + String[] intStrs =3D StringTokenizerUtils.tokenizeToArray( version, delim= s, false ); int len =3D intStrs.length; int[] out =3D new int[ len ]; for (int i =3D 0; i < len; ++i) @@ -179,4 +186,4 @@ else return 0; } =2D} \ Kein Zeilenumbruch am Dateiende. +} It ignores the extra part and restores the original behaviour for such version strings. regards Dirk =2D-=20 _____________________________________________________________________ RISC: Relegate Important Stuff to Compiler |