-
Notifications
You must be signed in to change notification settings - Fork 477
Make auths classes in Authorizations #2777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I believe that this is part of the public API. I'm not sure if this violates our policy, but I think it might. |
|
This change is causing a failure in |
Yeah, its definitely in the public API. I am not sure what the use case would be for using the Java serialization of the Auths though.
The question would be, if keeping the class serializable exposes a possible security flaw... is it worth breaking any serialization that a user may be using? |
Is there a security flaw? I believe the solution for #2776 in regards to this class is to mark these fields as |
I don't know.
That may be a better fix. But I think this would still break the serialization if a user extended Authorizations. I am going to write a test to experiment. My point being, if we are going to break the serialization to fix the warning, lets just get rid of it. |
|
If you remove the |
|
I wrote a simple test that writes and reads the Authorizations object and it passes on main. I think changing the serialization breaks the API either way: fields marked transient: Exception in toString(): java.lang.NullPointerException: Cannot invoke "java.util.Set.iterator()" because "this.auths" is null Dropped serializable: java.io.NotSerializableException: org.apache.accumulo.core.security.Authorizations Here is the test I added to AuthorizationsTest: @Test
public void testSerializable() throws Exception {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(bytesOut);
Authorizations auths = new Authorizations("foo");
outputStream.writeObject(auths);
outputStream.flush();
ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut.toByteArray());
ObjectInputStream inputStream = new ObjectInputStream(bytesIn);
Authorizations readObject = (Authorizations) inputStream.readObject();
assertEquals(auths, readObject);
}
|
|
in the case where you marked the fields transient, then you just need to protect against NPE in equals() ? EDIT: I think your serialization / deserialization worked with |
The |
|
Can't you just make ByteSequence serializable? ArrayList and HashSet already are. |
|
Its kinda neat that Java 18 found this. @milleruntime would you happen to have the error/warn message? I am curious what it said. Trying to understand the implications of removing the interface on binary compat I was looking at : https://wiki.eclipse.org/Evolving_Java-based_APIs_2 Reading that doc it seems like removing it may only break binary compat in the case where code is casting to Serializable. Does that interpretation seem correct? Since serialization did not work, maybe no one was doing that and its ok to remove if code that was not casting to Serializable is ok. |
I currently only have Java 18 in my IDE and this is all it is saying: workspace/accumulo/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java:47:29 java: non-transient instance field of a serializable class declared with a non-serializable type
I will take a look at that link, thanks.
So the serialization of |
It looks like we may not have to. By changing the private types from interfaces to classes, the warnings went away: - private Set<ByteSequence> auths = new HashSet<>();
- private List<byte[]> authsList = new ArrayList<>(); // sorted order
+ private final HashSet<ByteSequence> auths = new HashSet<>();
+ private final ArrayList<byte[]> authsList = new ArrayList<>(); // sorted order |
|
If a user is doing the following: but never serializes or deserializes the object, then according to the JLS they will get a |
It looks like all the serialization done for
Authorizationsis done with custom methods that we have created over the years. I am not sure why we need the interface on the class anymore.