Skip to content

Commit

Permalink
Fixes weird condition where some kind of JBoss classloader monkeybusi…
Browse files Browse the repository at this point in the history
…ness causes not found classes to not throw ClassNotFoundException. Fixes OGNL-13.
  • Loading branch information
jkuhnert committed May 5, 2007
1 parent 3ea69e1 commit 5c0443d
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 92 deletions.
161 changes: 81 additions & 80 deletions OGNL.iws

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<project name="ognl" default="jar" basedir=".">
<project name="ognl" default="jar" basedir="." >

<import file="osbuild.xml"/>
<import file="osbuild.xml" />

<path id="junit.cp">
<pathelement location="${build.test}"/>
Expand Down
5 changes: 3 additions & 2 deletions osbuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<property name="compile.version" value="1.5"/>

<property file="build.properties"/>
<property file="release.properties"/>

<property name="lib" value="lib"/>
<property name="lib.core" value="${lib}/core"/>
Expand Down Expand Up @@ -87,11 +86,13 @@
</copy>
</target>

<!-- <taskdef classpathref="${ant.home}/lib/clover.jar" name="clover-setup"/> -->

<target name="test" depends="junit-check,clover-check,compile">
<taskdef resource="clovertasks"/>
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

<mkdir dir="${build.clover}"/>

<clover-setup initString="${build.clover}/coverage.db">
<files>
<exclude name="src/test/**/*.java"/>
Expand Down
5 changes: 4 additions & 1 deletion src/java/ognl/OgnlRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,9 @@ public static Object callStaticMethod(OgnlContext context, String className, Str
{
try {
Class targetClass = classForName(context, className);
if (targetClass == null)
throw new ClassNotFoundException("Unable to resolve class with name " + className);

MethodAccessor ma = getMethodAccessor(targetClass);

return ma.callStaticMethod(context, targetClass, methodName, args);
Expand Down Expand Up @@ -1641,7 +1644,7 @@ public static void setMethodAccessor(Class cls, MethodAccessor accessor)
}

public static MethodAccessor getMethodAccessor(Class cls)
throws OgnlException
throws OgnlException
{
MethodAccessor answer = (MethodAccessor) getHandler(cls, methodAccessors);
if (answer != null)
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/ognl/test/Performance.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ public static void main(String[] args)
MAX_TIME = maxTime;
MAX_ITERATIONS = maxIterations;

Thread.sleep(2500);
System.out.println("\n\n============================================================================\n");


Thread.sleep(2500);
runTests(tests, true);
/*
Thread.sleep(2000);

//Thread.sleep(2000);

System.out.println("\n\n============================================================================\n");
runTests(tests);
*/
// runTests(tests);

} catch (Exception ex) {
ex.printStackTrace();
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/ognl/test/PropertyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public class PropertyTest extends OgnlTestCase
{ BEAN, "two.hasChildren('a')", Boolean.FALSE},
{ ROOT, "sorted ? (readonly ? 'currentSortDesc' : 'currentSortAsc') : 'currentSortNone'", "currentSortAsc"},
{ ROOT, "getAsset( (width?'Yes':'No')+'Icon' )", "YesIcon"},
{ MODEL, "(unassignedCopyModel.optionCount > 0 && canApproveCopy) || entry.copy.size() > 0", Boolean.TRUE }
{ MODEL, "(unassignedCopyModel.optionCount > 0 && canApproveCopy) || entry.copy.size() > 0", Boolean.TRUE },
{ ROOT, "flyingMonkey", Boolean.TRUE}
};

public static String formatValue(int millis, boolean b1, boolean b2)
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/org/ognl/test/TestOgnlRuntime.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.ognl.test;

import junit.framework.TestCase;
import ognl.MethodFailedException;
import ognl.Ognl;
import ognl.OgnlContext;
import ognl.OgnlRuntime;
import org.ognl.test.objects.*;

Expand Down Expand Up @@ -51,4 +54,20 @@ public void test_Get_Read_Method()

assertEquals("isPageBreakAfter", m.getName());
}

public void test_Call_Static_Method_Invalid_Class()
{

try {

OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null);
OgnlRuntime.callStaticMethod(context, "made.up.Name", "foo", null);

fail("ClassNotFoundException should have been thrown by previous reference to <made.up.Name> class.");
} catch (Exception et) {

assertTrue(MethodFailedException.class.isInstance(et));
assertTrue(et.getMessage().indexOf("made.up.Name") > -1);
}
}
}
5 changes: 5 additions & 0 deletions src/test/java/org/ognl/test/objects/Root.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,9 @@ public Long getCurrentDeliveryId()
{
return 1l;
}

public Boolean isFlyingMonkey()
{
return Boolean.TRUE;
}
}

0 comments on commit 5c0443d

Please sign in to comment.