svn commit: r1226224 - in /ofbiz/branches/release11.04: ./ framework/base/src/org/ofbiz/base/util/ObjectType.java framework/base/src/org/ofbiz/base/util/UtilIO.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1226224 - in /ofbiz/branches/release11.04: ./ framework/base/src/org/ofbiz/base/util/ObjectType.java framework/base/src/org/ofbiz/base/util/UtilIO.java

jleroux@apache.org
Author: jleroux
Date: Sun Jan  1 10:00:04 2012
New Revision: 1226224

URL: http://svn.apache.org/viewvc?rev=1226224&view=rev
Log:
"Applied fix from trunk for revision: 1226223"
------------------------------------------------------------------------
r1226223 | jleroux | 2012-01-01 10:57:50 +0100 (dim., 01 janv. 2012) | 9 lines

A patch from Martin Kreidenweis "Deserialization of arrays with UtilObject.getObject() throws ClassNotFoundException" https://issues.apache.org/jira/browse/OFBIZ-4295

Deserialization of arrays with UtilObject.getObject() throws a ClassNotFoundException. This happened to us when we enabled the distributed cache clear feature and it was sending arrays of EntityExpr objects to other OFBiz instances.

The reason is, that the org.ofbiz.base.util.ObjectInputStream calls classLoader.loadClass(name) directly instead of using Class.forName(name, init, classLoader).
According to java bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6446627 ClassLoader.loadClass() is not intended to being used this way and doesn't support loading arrays.

jleroux: Sun/Oracle is pretty clear about that <<[When you want to reflectively load a class by name initiated using a specific class loader, you should not invoke that loader's public loadClass method directly-- instead, you should always use the static three-argument Class.forName method.  The ClassLoader.loadClass instance method is more intended for delegation from one class loader to another within a class loading operation (although this is a common confusion and not well described in the documentation).  In other words, replace L.loadClass(N) with Class.forName(N,false,L).  The Class.forName invocation may eventually end up invoking loadClass on the specified loader, but only after taking care of some other aspects of the VM's standard symbolic class name resolution process-- the significant bit in this case being the support for loading/creation of array classes.]>> More at the link above

------------------------------------------------------------------------


Modified:
    ofbiz/branches/release11.04/   (props changed)
    ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/ObjectType.java
    ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilIO.java

Propchange: ofbiz/branches/release11.04/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan  1 10:00:04 2012
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4:951708-952957
 /ofbiz/branches/jquery:952958-1044489
 /ofbiz/branches/multitenant20100310:921280-927264
-/ofbiz/trunk:1100197,1100880,1104423,1131144,1131396,1132496,1132749,1133353,1134990,1135199,1135686,1135929,1137201,1137433,1137435,1138463,1138485,1139346,1139385,1139504,1139521,1140358,1140362,1140375,1140469,1144537,1144791,1153073,1153768,1158124,1158126,1158608,1159080,1163036,1163093,1163533,1165130,1166591,1167116,1167314,1167480,1167501,1167510,1167517,1167606,1172213,1172243,1174964,1175130,1175135,1175143,1177128,1178175,1178199,1180398,1181878,1182259,1182310,1182731,1182858,1183651,1184906,1184996,1184999,1185179,1187515,1187528,1187933,1187944,1188042,1188564,1189592,1189601,1190134,1194958,1196778,1199276,1199450,1200207,1201110,1201125,1201941,1203350,1203776,1206507,1206690,1208335,1209250,1209362,1210193,1210211,1212147,1214124,1220298,1221889,1221913,1222105,1222478,1226055,1226065
+/ofbiz/trunk:1100197,1100880,1104423,1131144,1131396,1132496,1132749,1133353,1134990,1135199,1135686,1135929,1137201,1137433,1137435,1138463,1138485,1139346,1139385,1139504,1139521,1140358,1140362,1140375,1140469,1144537,1144791,1153073,1153768,1158124,1158126,1158608,1159080,1163036,1163093,1163533,1165130,1166591,1167116,1167314,1167480,1167501,1167510,1167517,1167606,1172213,1172243,1174964,1175130,1175135,1175143,1177128,1178175,1178199,1180398,1181878,1182259,1182310,1182731,1182858,1183651,1184906,1184996,1184999,1185179,1187515,1187528,1187933,1187944,1188042,1188564,1189592,1189601,1190134,1194958,1196778,1199276,1199450,1200207,1201110,1201125,1201941,1203350,1203776,1206507,1206690,1208335,1209250,1209362,1210193,1210211,1212147,1214124,1220298,1221889,1221913,1222105,1222478,1226055,1226065,1226223

Modified: ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=1226224&r1=1226223&r2=1226224&view=diff
==============================================================================
--- ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/ObjectType.java Sun Jan  1 10:00:04 2012
@@ -106,7 +106,7 @@ public class ObjectType {
         if (loader == null) loader = Thread.currentThread().getContextClassLoader();
 
         try {
-            theClass = loader.loadClass(className);
+            theClass = Class.forName(className, true, loader);
         } catch (Exception e) {
             theClass = classCache.get(className);
             if (theClass == null) {

Modified: ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilIO.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilIO.java?rev=1226224&r1=1226223&r2=1226224&view=diff
==============================================================================
--- ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilIO.java (original)
+++ ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilIO.java Sun Jan  1 10:00:04 2012
@@ -378,7 +378,7 @@ public final class UtilIO {
             for (i = offset; i < length && buffer[i] != ':'; i++);
             if (i > offset && i < length) {
                 String className = new String(buffer, offset, i);
-                Class<?> type = ClassLoaderContainer.getClassLoader().loadClass(className);
+                Class<?> type = Class.forName(className, true, ClassLoaderContainer.getClassLoader());
                 if (buffer[length - 1] == '\n') {
                     length--;
                 }