Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
8301863: ObjectInputFilter example incorrectly calls rejectUndecidedC…
Browse files Browse the repository at this point in the history
…lass

Reviewed-by: lancea
  • Loading branch information
Roger Riggs committed Feb 8, 2023
1 parent 1330d4e commit 6f460e4
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/java.base/share/classes/java/io/ObjectInputFilter.java
Expand Up @@ -187,8 +187,11 @@
*
* This class shows how an application provided filter factory can combine filters
* to check every deserialization operation that takes place in a thread.
* It defines a thread-local variable to hold the thread-specific filter, and constructs a filter factory
* that composes that filter with the static JVM-wide filter and the stream-specific filter.
* It defines a thread-local variable to hold the thread-specific filter, and construct a filter factory
* that composes that filter with the static JVM-wide filter and the stream-specific filter,
* rejecting any classes not handled by those two filters.
* If a stream specific filter is set and does not accept or reject a class,
* the combined JVM-wide filter and thread filter is applied.
* The {@code doWithSerialFilter} method does the setup of the thread-specific filter
* and invokes the application provided {@link Runnable Runnable}.
*
Expand All @@ -207,26 +210,18 @@
* // Called from the OIS constructor or perhaps OIS.setObjectInputFilter with no current filter
* var filter = filterThreadLocal.get();
* if (filter != null) {
* // Wrap the filter to reject UNDECIDED results
* filter = ObjectInputFilter.rejectUndecidedClass(filter);
* // Merge to invoke the thread local filter and then the JVM-wide filter (if any)
* filter = ObjectInputFilter.merge(filter, next);
* return ObjectInputFilter.rejectUndecidedClass(filter);
* }
* if (next != null) {
* // Merge the next filter with the thread filter, if any
* // Initially this is the static JVM-wide filter passed from the OIS constructor
* // Wrap the filter to reject UNDECIDED results
* filter = ObjectInputFilter.merge(next, filter);
* filter = ObjectInputFilter.rejectUndecidedClass(filter);
* }
* return filter;
* return (next == null) ? null : ObjectInputFilter.rejectUndecidedClass(next);
* } else {
* // Called from OIS.setObjectInputFilter with a current filter and a stream-specific filter.
* // The curr filter already incorporates the thread filter and static JVM-wide filter
* // and rejection of undecided classes
* // If there is a stream-specific filter wrap it and a filter to recheck for undecided
* // If there is a stream-specific filter merge to invoke it and then the current filter.
* if (next != null) {
* next = ObjectInputFilter.merge(next, curr);
* next = ObjectInputFilter.rejectUndecidedClass(next);
* return next;
* return ObjectInputFilter.merge(next, curr);
* }
* return curr;
* }
Expand Down

3 comments on commit 6f460e4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperIRL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tag jdk-20+35

@openjdk
Copy link

@openjdk openjdk bot commented on 6f460e4 Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperIRL The tag jdk-20+35 was successfully created.

Please sign in to comment.