• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()


  • Subject: Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 15 Apr 2016 23:12:32 +0000
  • Thread-topic: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()

Good catch!  It should use removeAll() not remove().



From: <webobjects-dev-bounces+chill=email@hidden> on behalf of Paul Hoadley <email@hidden>
Date: Friday, April 15, 2016 at 3:55 PM
To: Johann Werner <email@hidden>
Cc: WebObjects Development <email@hidden>
Subject: Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()

Hi Johann,

On 15 Apr 2016, at 11:53 pm, Johann Werner <email@hidden> wrote:

do you have an example where ERXEOControlUtilities.validateUniquenessOf() does not work because of ERXArrayUtilities.arrayMinusObject()? What is the exact error?

This is in the middle of a WOUnit test, so the error is that validateUniquenessOf() throws a “UniquenessViolationNewObject” because count == 1 at line 2417. This test passes with Wonder 6, fails with Wonder 7.

I doubt that object is not removed from the array, the only reason that comes to my mind would be that the editing context of object and that of the array are different so that equals() would return false but ERXEOControlUtilities.validateUniquenessOf() uses the same editing context for both params. Perhaps some other part is the cause of your problem?

I think I have narrowed it down: the behaviour of the old and new methods are different with respect to duplicate objects in the supplied array. Specifically, if the object to be removed is present more than once in the array, the old method removes all references to it, the new method removes a single reference to it. Here’s a demonstration:

publicclass ArrayTest {
publicstatic class Foo {

}


@Test
publicvoid arrayTest() {
Foo a = new Foo();
NSMutableArray<Foo> array = new NSMutableArray<Foo>();
array.add(a);
System.out.println("ArrayTest.arrayTest: array = " + array);
array.add(a);
System.out.println("ArrayTest.arrayTest: array = " + array);
NSArray<Foo> result = ERXArrayUtilities.arrayMinusObject(array, a);
System.out.println("ArrayTest.arrayTest: result = " + result);
return;
}
}

The old method gives this output:

ArrayTest.arrayTest: array = (net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: array = (net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca, net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: result = ()

and the new method gives this output:

ArrayTest.arrayTest: array = (net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: array = (net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca, net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: result = (net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)

Again, I know we agreed that Wonder 7 need not maintain backwards compatibility (and I still support this), I wonder whether this particular behavioural change was intended, and whether we should think about reverting it. I haven’t tested ERXEOControlUtilities.validateUniquenessOf(), in particular, outside WOUnit, and I don’t know why the fetch at 2405 would bring in two copies of the same object, but it does in this test, and the old behaviour of arrayMinusObject() accounted for that.

What do you think?

And while we’re here:

1. With the new method signature for arrayMinusArray(), WOUnit’s MockEditingContext can’t even find that method:

java.lang.NoSuchMethodError: er.extensions.foundation.ERXArrayUtilities.arrayMinusArray(Lcom/webobjects/foundation/NSArray;Lcom/webobjects/foundation/NSArray;)Lcom/webobjects/foundation/NSArray;
at com.wounit.rules.MockEditingContext.saveChanges(MockEditingContext.java:310)


It’s not immediately clear to me why this would be the case, as obviously NSArray implements Collection, and the new signature is:

public static <T> NSArray<T> arrayMinusArray(Collection<T> array, Collection<?> minus)

Any thoughts on this one? It’s a bit of a show-stopper for WOUnit at the moment.


-- 
Paul Hoadley
http://logicsquad.net/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
      • From: Paul Hoadley <email@hidden>
References: 
 >Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject() (From: Paul Hoadley <email@hidden>)
 >Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject() (From: Paul Hoadley <email@hidden>)

  • Prev by Date: Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
  • Next by Date: Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
  • Previous by thread: Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
  • Next by thread: Re: Issues with ERXArrayUtilities.arrayMinusArray() and arrayMinusObject()
  • Index(es):
    • Date
    • Thread