12 Replies Latest reply on Jul 19, 2012 3:35 AM by dimonv

    Issue on updating node properties of type "multiple reference"

    dimonv

      Hi all,

       

      we are facing a problem on updating a node ptoperty of type multiple reference. Instead of new array of references the property value remains the same.

      On debuging we saw in the methode org.modeshape.jcr.SessionCache.NodeEditor.setProperty(Name, Value[], int, boolean, boolean):

       

                     ...

                     assert jcrProp != null; 

                     JcrPropertyPayload propPayload = new JcrPropertyPayload(definition.getId(), propertyType, jcrProp);                                node.setProperty(dnaProp, definition.isMultiple(), propPayload);                

                     return jcrProp;

       

      dnaProp is updated value and jcrProp the old one. But any way the old wins on this update.

       

      Is it a bug? are there any fixes for that.

       

      Thanks a lot

        • 1. Re: Issue on updating node properties of type "multiple reference"
          rhauch

          Based upon the classes you reference, this is 2.x code. Are you using the latest (2.8.1.Final)?

           

           

                         ...

                         assert jcrProp != null; 

                         JcrPropertyPayload propPayload = new JcrPropertyPayload(definition.getId(), propertyType, jcrProp);                                node.setProperty(dnaProp, definition.isMultiple(), propPayload);                

                         return jcrProp;

           

          dnaProp is updated value and jcrProp the old one. But any way the old wins on this update.

          If you're using 2.8.1, the code you mention is near the end of this try block, and 'jcrProp' will be the old javax.jcr.Property (e.g., JcrMultiValueProperty or JcrSingleValueProperty) instance that doesn't hold the value itself but is instead a wrapper around the internal object (e.g., the "dnaProp" object) that actually holds the value. We use this wrapper so that your application can hold onto the javax.jcr.Property object, but under the covers we can change the apparent value without actually using mutable objects. (It's kind of complicated.)

           

          Anyway, at that point in the code, 'dnaProp' should contain the new values. Does it? If so, does the Property value have the correct value before saving the session? What about after saving the session?

           

          BTW, if you could create a small repeatable test case that exhibits this behavior, we could use it to identify the particular case where it fails, and more quickly identify a fix or a workaround.

          • 2. Re: Issue on updating node properties of type "multiple reference"
            dimonv

            Hi Randall,

             

            yes we are using 2.8.1.Final

            Randall Hauch wrote:

             

            Anyway, at that point in the code, 'dnaProp' should contain the new values. Does it?

            Yes, it does. But anyway node node.setProperty(dnaProp, definition.isMultiple(), propPayload);

            the property of node didn't change.

             

            Thanks for a detailed explanation. Yes the session will be saved.

            • 3. Re: Issue on updating node properties of type "multiple reference"
              rhauch

              But anyway node node.setProperty(dnaProp, definition.isMultiple(), propPayload);

              the property of node didn't change.

               

              Any chance you could trace into that method, or create a simple test case that replicates the problem? The reason I ask is that we have quite a few test cases (including a number of them in the TCK tests) that do this exact thing, and they're all working properly. My guess is there is something unique to your usage that our tests don't cover. 

              • 4. Re: Issue on updating node properties of type "multiple reference"
                dimonv

                Hi Randall,

                 

                I attached a sample reproducing the issue. Well, it's a maven project. You can import it into eclipse or build it with maven from command line.

                • 5. Re: Issue on updating node properties of type "multiple reference"
                  dimonv

                  I have uploaded a modified sample. It illustrats the issue better.

                  • 6. Re: Issue on updating node properties of type "multiple reference"
                    dimonv

                    Hi Randall,

                     

                    I've debugged further and found somethind out. The same join query when executed again after relation updates returns an empty result set, because the right join's tupels do not include jcr:uuid value.

                    I saw also in Lucene code:

                     

                      final Document doc(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException {
                        seekIndex(n);
                        long position = indexStream.readLong();
                        fieldsStream.seek(position);
                    
                        Document doc = new Document();
                        int numFields = fieldsStream.readVInt();
                        out: for (int i = 0; i < numFields; i++) {
                          int fieldNumber = fieldsStream.readVInt();
                          FieldInfo fi = fieldInfos.fieldInfo(fieldNumber);
                          FieldSelectorResult acceptField = fieldSelector == null ? FieldSelectorResult.LOAD : fieldSelector.accept(fi.name);
                    .....

                     

                    that on loading uuid field name in the org.apache.lucene.index.FieldsReader.fieldInfos attribute was "mode:uuid" instread of "jct:uuid". No idea why. On first query execution this field was still "jcr:uuid".

                     

                    Regards

                    • 7. Re: Issue on updating node properties of type "multiple reference"
                      dimonv

                      Hi all,

                       

                      we are in a kind of desperate situation: immediately before release of our system we found out this issue.

                       

                      If anybody is facing the same problem and can provide a hint or a workaround for that we would very appreciate.

                       

                      Regards

                      • 8. Re: Issue on updating node properties of type "multiple reference"
                        hchiorean

                        Hi,

                         

                        I'll have a look at this issue tomorrow and let you know what I find out.

                        • 9. Re: Issue on updating node properties of type "multiple reference"
                          hchiorean

                          Hi Dmitri,

                           

                          Based on the test case you provided, I've tracked down the issue and opened a JIRA for it: https://issues.jboss.org/browse/MODE-1553.

                          I'll fix it ASAP and discuss with Randall how we can provide you guys with a patch (or a new 2.x release)

                          • 10. Re: Issue on updating node properties of type "multiple reference"
                            rhauch

                            We've fixed this in the '2.x' branch. We've got a handful of other fixes on that branch, so now's a great time for us to release 2.8.2.Final. I'm in the process of merging several other fixes, and then I'll start the release. Stay tuned.

                            • 11. Re: Issue on updating node properties of type "multiple reference"
                              rhauch

                              ModeShape 2.8.2.Final is now available (see the announcement) and includes only bug fixes (including a fix for the issue you ran into; see MODE-1553). Please give the release a try.

                              • 12. Re: Issue on updating node properties of type "multiple reference"
                                dimonv

                                Hi Randall,

                                 

                                many thanks for your rapid help on this and the other issues.

                                 

                                Kind regards,

                                Dmitri