Issue Details (XML | Word | Printable)

Key: HARMONY-6043
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Tony Wu
Reporter: Kevin Zhou
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Harmony

[classlib] [security] UnresolvedPermission.equals(Object) doesn't works well

Created: 12/Dec/08 06:27 AM   Updated: 22/Dec/08 03:25 AM
Return to search
Component/s: Classlib
Affects Version/s: 5.0M8
Fix Version/s: 5.0M9

Time Tracking:
Original Estimate: 24h
Original Estimate - 24h
Remaining Estimate: 24h
Remaining Estimate - 24h
Time Spent: Not Specified
Remaining Estimate - 24h

File Attachments:
  Size
File Licensed for inclusion in ASF works HARMONY-6043.diff 2008-12-12 06:29 AM Kevin Zhou 12 kB
File Licensed for inclusion in ASF works HARMONY-6043v2.diff 2008-12-19 04:23 AM Kevin Zhou 1 kB

Estimated Complexity: Moderate
Resolution Date: 22/Dec/08 03:25 AM


 Description  « Hide
Given a test case[1], RI works well while HARMONY fails.

[1] UnresolvedPermissionTest
public class UnresolvedPermissionTest extends TestCase {
    public static final String type = "java.util.PropertyPermission";
    public static final String name = "os.name";
    public static final String action = "write,read";
    public void test_Scenario0() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                null);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                null);
        assertEquals(up1, up2);
    }

    public void test_Scenario1() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                null);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[0]);
        assertFalse(up1.equals(up2));
    }

    public void test_Scenario2() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                null);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[2]);
        assertFalse(up1.equals(up2));
    }

    public void test_Scenario3() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[0]);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[0]);
        assertEquals(up1, up2);
    }

    public void test_Scenario4() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[0]);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[2]);
        assertFalse(up1.equals(up2));
    }

    public void test_Scenario5() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[2]);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[2]);
        try {
            up1.equals(up2);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // Expected
        }
    }

    public void test_Scenario6() {
        UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[2]);
        UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
                new java.security.cert.Certificate[5]);
        assertFalse(up1.equals(up2));
    }
}

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kevin Zhou added a comment - 12/Dec/08 06:29 AM
Would you please help to try it?

Kevin Zhou added a comment - 12/Dec/08 06:36 AM
It seems that Harmony's behavior is different from RI.
Already make a patch attached.




Kevin Zhou added a comment - 12/Dec/08 06:51 AM
Patch applied to r725920.

Alexey Varlamov added a comment - 12/Dec/08 06:28 PM
Guys, the patch is not really good.. One must make defensive copy when setting array properties - plain assigment of array reference is unsafe.

Also, it is not really clear from the report what the problem is? I have no Harmony build at hand nor RI 1.6 nearby, could you please cite console logs for the both runtimes?


Alexey Varlamov added a comment - 12/Dec/08 06:35 PM
Looking on the test source, I'd rather consider this as non-bug difference.
Especially, test_Scenario5 vs test_Scenario6 is a true find - do we really have to comply?

Kevin Zhou added a comment - 19/Dec/08 04:23 AM
Would you please help to try it?

Tony Wu added a comment - 22/Dec/08 03:25 AM
2nd patch applied at r728589 with handling to NPE. Thanks Kevin. Please verify if it fixes as you expected.