Skip to content
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

Remove Serializable interface from Violation class and EventObject extension from AuditEvent #12681

Closed
rnveach opened this issue Jan 25, 2023 · 5 comments

Comments

@rnveach
Copy link
Member

rnveach commented Jan 25, 2023

Since we don't use serialization, we will remove this class being serializable as it is not serializable due to arg field.

Serialization was added at d2af4ac#diff-52efb9bb7c26b577e3885a9539eac7d5R42 titled Apply parts of patch #1952556 fixing some FindBugs bugs. Thanks to Travis Schneeberger.

http://git.net/ml/java.audit.checkstyle.devel/2008-04/msg00067.html

Findbugs does produce this error if I remove the serialization:

[INFO] Class com.puppycrawl.tools.checkstyle.api.AuditEvent defines non-transient non-serializable instance field localizedMessage [com.puppycrawl.tools.checkstyle.api.AuditEvent] In AuditEvent.java SE_BAD_FIELD

This is because AuditEvent is serialized through inheritance of EventObject.
Such inheritance also should be removed.

============

Now this is become why is AuditEvent serialized and need EventObject.


Second problem of serialization:
Detected by IDEA inspection and Sonar Inspection Make "args" transient or serializable.
https://sonarcloud.io/project/issues?id=org.checkstyle%3Acheckstyle&issues=AW9t2w2MYD2QG1pPXIUJ&open=AW9t2w2MYD2QG1pPXIUJ

/**
* Arguments for MessageFormat.
*
* @noinspection NonSerializableFieldInSerializableClass
* @noinspectionreason NonSerializableFieldInSerializableClass - usage of
* 'Serializable' for this api class
* is considered as mistake now, but we do not break api without
* good reason
*/
private final Object[] args;

Slightly related problem: #7488 (comment) but a different approach.

=====

PR Discussion resolution for second problem:

Changing args to something more serializable would be a huge break for whole Checkstyle. This would impact property files which use special properties of MessageFormat to format the argument into a meaningful display.

@nitishmalang
Copy link

please assign me i can work on this issue

@rnveach
Copy link
Member Author

rnveach commented Jan 26, 2023

@nitishmalang This is already taken and has a PR awaiting review.

rnveach added a commit to rnveach/checkstyle that referenced this issue Jan 27, 2023
rnveach added a commit to rnveach/checkstyle that referenced this issue Feb 3, 2023
@romani
Copy link
Member

romani commented Feb 13, 2023

Should we title issue something as Remove serializable interface from Violation class ?

@rnveach
Copy link
Member Author

rnveach commented Feb 13, 2023

I am fine with that.

@romani romani changed the title Resolve Violation class has non-serializbale fields in class Remove serializable interface from Violation class Feb 18, 2023
@romani romani changed the title Remove serializable interface from Violation class Remove Serializable interface from Violation class and EventObject extension from AuditEvent Feb 19, 2023
rnveach added a commit to rnveach/checkstyle that referenced this issue Feb 19, 2023
rnveach added a commit to rnveach/checkstyle that referenced this issue Feb 20, 2023
rnveach added a commit to rnveach/checkstyle that referenced this issue Feb 21, 2023
@nrmancuso
Copy link
Member

Closed via #12675

@nrmancuso nrmancuso added this to the 10.8.0 milestone Feb 21, 2023
Zopsss pushed a commit to Zopsss/checkstyle that referenced this issue Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants