You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Kevin Sutter (JIRA)" <ji...@apache.org> on 2010/03/11 21:44:27 UTC

[jira] Created: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Better parameter validation on StoreCache.pinAll() method
---------------------------------------------------------

                 Key: OPENJPA-1563
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
             Project: OpenJPA
          Issue Type: Improvement
          Components: datacache
    Affects Versions: 2.0.0-beta2, 2.0.0
            Reporter: Kevin Sutter
            Assignee: Rick Curtis
            Priority: Minor


Validation of the second parameter on StoreCache.pinAll could be better.  Currently, we assume that the list of oids provided are valid ids for the Class instances being cached.  But, if the collection of Objects passed in are not actual ids, then we end up reserving spots in the cache that never get utilized.

    /**
     * Pin the data for the given oids to the cache.
     */
    public void pinAll(Class cls, Object... oids);

Since the Class type is also passed in, we should be able to validate that the oids passed in are valid.  At a minimum, checking if they are oids in the first place would be a good catch.  Currently, we do nothing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Posted by Web developer <we...@gmail.com>.
I have the following exception in junit tests:

enhance.all.entities:
     [echo]  running enhancer
283  WARN   [main] openjpa.Runtime - The configuration property named
"openjpa.loglevel" was not recognized and will be ignored, although the name
closely matches a valid property called "openjpa.Log".



org.apache.commons.lang.exception.NestableRuntimeException: Error extracting
class information from
"/home/webautomator/apache-openjpa-2.0.0-beta3-source/openjpa-persistence-jdbc/target/test-classes/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache$SQLAuditor.class".
    at
org.apache.openjpa.lib.meta.ClassArgParser.parseTypeNames(ClassArgParser.java:226)
    at
org.apache.openjpa.lib.meta.ClassArgParser.parseTypes(ClassArgParser.java:161)
    at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4637)
    at
org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89)
    at
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:171)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at
org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
    at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at
org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 762
    at
serp.bytecode.lowlevel.ConstantPoolTable.parse(ConstantPoolTable.java:53)
    at
serp.bytecode.lowlevel.ConstantPoolTable.<init>(ConstantPoolTable.java:23)
    at
serp.bytecode.lowlevel.ConstantPoolTable.<init>(ConstantPoolTable.java:30)
    at
org.apache.openjpa.lib.meta.ClassArgParser.getFromClass(ClassArgParser.java:324)
    at
org.apache.openjpa.lib.meta.ClassArgParser.getFromClassFile(ClassArgParser.java:308)
    at
org.apache.openjpa.lib.meta.ClassArgParser.parseTypeNames(ClassArgParser.java:217)
    ... 58 more
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while
executing this line:
/home/webautomator/apache-openjpa-2.0.0-beta3-source/openjpa-persistence-jdbc/src/main/ant/enhancer.xml:51:
The following error occurred while executing this line:
/home/webautomator/apache-openjpa-2.0.0-beta3-source/openjpa-persistence-jdbc/src/main/ant/enhancer.xml:84:
org.apache.commons.lang.exception.NestableRuntimeException: Error extracting
class information from
"/home/webautomator/apache-openjpa-2.0.0-beta3-source/openjpa-persistence-jdbc/target/test-classes/org/apache/openjpa/persistence/jdbc/sqlcache/TestPreparedQueryCache$SQLAuditor.class".

762
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 200 minutes 23 seconds
[INFO] Finished at: Mon May 17 17:16:19 EEST 2010
[INFO] Final Memory: 57M/143M
[INFO]
------------------------------------------------------------------------

Please help anyone. John

2010/5/17 Rick Curtis (JIRA) <ji...@apache.org>

>
>    [
> https://issues.apache.org/jira/browse/OPENJPA-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12868231#action_12868231]
>
> Rick Curtis commented on OPENJPA-1563:
> --------------------------------------
>
> Nice catch Milosz.
>
> Fixed the problem and modified an existing test case to hit this method.
>
> > Better parameter validation on StoreCache.pinAll() method
> > ---------------------------------------------------------
> >
> >                 Key: OPENJPA-1563
> >                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
> >             Project: OpenJPA
> >          Issue Type: Improvement
> >          Components: datacache
> >    Affects Versions: 2.0.0-beta2, 2.0.0
> >            Reporter: Kevin Sutter
> >            Assignee: Rick Curtis
> >            Priority: Minor
> >             Fix For: 2.1.0
> >
> >
> > Validation of the second parameter on StoreCache.pinAll could be better.
>  Currently, we assume that the list of oids provided are valid ids for the
> Class instances being cached.  But, if the collection of Objects passed in
> are not actual ids, then we end up reserving spots in the cache that never
> get utilized.
> >     /**
> >      * Pin the data for the given oids to the cache.
> >      */
> >     public void pinAll(Class cls, Object... oids);
> > Since the Class type is also passed in, we should be able to validate
> that the oids passed in are valid.  At a minimum, checking if they are oids
> in the first place would be a good catch.  Currently, we do nothing.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

[jira] Updated: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis updated OPENJPA-1563:
---------------------------------

    Fix Version/s: 2.1.0

> Better parameter validation on StoreCache.pinAll() method
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1563
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: datacache
>    Affects Versions: 2.0.0-beta2, 2.0.0
>            Reporter: Kevin Sutter
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.1.0
>
>
> Validation of the second parameter on StoreCache.pinAll could be better.  Currently, we assume that the list of oids provided are valid ids for the Class instances being cached.  But, if the collection of Objects passed in are not actual ids, then we end up reserving spots in the cache that never get utilized.
>     /**
>      * Pin the data for the given oids to the cache.
>      */
>     public void pinAll(Class cls, Object... oids);
> Since the Class type is also passed in, we should be able to validate that the oids passed in are valid.  At a minimum, checking if they are oids in the first place would be a good catch.  Currently, we do nothing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Posted by "Milosz Tylenda (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867897#action_12867897 ] 

Milosz Tylenda commented on OPENJPA-1563:
-----------------------------------------

Hi Rick, I am afraid this will end up in StackOverlfowError :)

+    public static Collection<Object> toOpenJPAObjectIds(ClassMetaData meta, Collection<Object> oids) {
+        return toOpenJPAObjectIds(meta, oids);


> Better parameter validation on StoreCache.pinAll() method
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1563
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: datacache
>    Affects Versions: 2.0.0-beta2, 2.0.0
>            Reporter: Kevin Sutter
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.1.0
>
>
> Validation of the second parameter on StoreCache.pinAll could be better.  Currently, we assume that the list of oids provided are valid ids for the Class instances being cached.  But, if the collection of Objects passed in are not actual ids, then we end up reserving spots in the cache that never get utilized.
>     /**
>      * Pin the data for the given oids to the cache.
>      */
>     public void pinAll(Class cls, Object... oids);
> Since the Class type is also passed in, we should be able to validate that the oids passed in are valid.  At a minimum, checking if they are oids in the first place would be a good catch.  Currently, we do nothing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rick Curtis resolved OPENJPA-1563.
----------------------------------

    Resolution: Fixed

Comitted rev 940077 to trunk.

> Better parameter validation on StoreCache.pinAll() method
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1563
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: datacache
>    Affects Versions: 2.0.0-beta2, 2.0.0
>            Reporter: Kevin Sutter
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.1.0
>
>
> Validation of the second parameter on StoreCache.pinAll could be better.  Currently, we assume that the list of oids provided are valid ids for the Class instances being cached.  But, if the collection of Objects passed in are not actual ids, then we end up reserving spots in the cache that never get utilized.
>     /**
>      * Pin the data for the given oids to the cache.
>      */
>     public void pinAll(Class cls, Object... oids);
> Since the Class type is also passed in, we should be able to validate that the oids passed in are valid.  At a minimum, checking if they are oids in the first place would be a good catch.  Currently, we do nothing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12868231#action_12868231 ] 

Rick Curtis commented on OPENJPA-1563:
--------------------------------------

Nice catch Milosz.

Fixed the problem and modified an existing test case to hit this method.

> Better parameter validation on StoreCache.pinAll() method
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1563
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: datacache
>    Affects Versions: 2.0.0-beta2, 2.0.0
>            Reporter: Kevin Sutter
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.1.0
>
>
> Validation of the second parameter on StoreCache.pinAll could be better.  Currently, we assume that the list of oids provided are valid ids for the Class instances being cached.  But, if the collection of Objects passed in are not actual ids, then we end up reserving spots in the cache that never get utilized.
>     /**
>      * Pin the data for the given oids to the cache.
>      */
>     public void pinAll(Class cls, Object... oids);
> Since the Class type is also passed in, we should be able to validate that the oids passed in are valid.  At a minimum, checking if they are oids in the first place would be a good catch.  Currently, we do nothing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-1563) Better parameter validation on StoreCache.pinAll() method

Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12863030#action_12863030 ] 

Rick Curtis commented on OPENJPA-1563:
--------------------------------------

One thing I want to point out is that JPAFacadeHelper.toOpenJPAObjectId(..) will now throw a RuntimeException. This could cause a behavior change for any users currently using the java.persistence.Cache interface improperly. 

For example, if they call javax.persistence.Cache.evict(Class, oid) and oid isn't a valid oid for the provided Class, we will now throw a UserException. 

> Better parameter validation on StoreCache.pinAll() method
> ---------------------------------------------------------
>
>                 Key: OPENJPA-1563
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1563
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: datacache
>    Affects Versions: 2.0.0-beta2, 2.0.0
>            Reporter: Kevin Sutter
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.1.0
>
>
> Validation of the second parameter on StoreCache.pinAll could be better.  Currently, we assume that the list of oids provided are valid ids for the Class instances being cached.  But, if the collection of Objects passed in are not actual ids, then we end up reserving spots in the cache that never get utilized.
>     /**
>      * Pin the data for the given oids to the cache.
>      */
>     public void pinAll(Class cls, Object... oids);
> Since the Class type is also passed in, we should be able to validate that the oids passed in are valid.  At a minimum, checking if they are oids in the first place would be a good catch.  Currently, we do nothing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.