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

Jetty 12 immutable ee10 configurations #9724

Merged
merged 11 commits into from
May 13, 2023

Conversation

gregw
Copy link
Contributor

@gregw gregw commented May 2, 2023

From #9686 making Configurations immutable

gregw added 2 commits May 2, 2023 11:30
WIP made abstract builder
WIP making more Configurations immutable
@gregw gregw requested a review from janbartel May 2, 2023 11:06
@gregw
Copy link
Contributor Author

gregw commented May 2, 2023

@janbartel would be good to get review and/or help as I go on this one.

gregw added 4 commits May 2, 2023 14:29
WIP don't clone Configurations
WIP don't clone Configurations
…table-ee10-configurations

# Conflicts:
#	jetty-ee10/jetty-ee10-quickstart/src/main/java/org/eclipse/jetty/ee10/quickstart/QuickStartGeneratorConfiguration.java
#	jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/JaasConfiguration.java
@gregw gregw marked this pull request as ready for review May 3, 2023 09:59
@gregw gregw requested a review from lachlan-roberts May 4, 2023 17:41
@gregw
Copy link
Contributor Author

gregw commented May 5, 2023

@janbartel nudge

Copy link
Contributor

@janbartel janbartel left a comment

Choose a reason for hiding this comment

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

Mostly fine, just minor niggles.

I need to be convinced about the serverDefault though.

And an alternative to the oddly inverted builder pattern?

@@ -68,6 +61,12 @@ public IncludeExcludeSet()
this(HashSet.class);
}

public IncludeExcludeSet<T, P> asImmutable()
{
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

A new TODO in new code??!

@@ -176,7 +176,7 @@ public static Configurations setServerDefault(Server server)
return configurations;
configurations = getServerDefault(server);
server.addBean(configurations);
server.setAttribute(Configuration.ATTR, null);
server.setAttribute(SERVER_DEFAULT_ATTR, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really not server defaults, they are specifically environment defaults. If an ee9 context setup was to call this method, and then an ee10 called the same method, one would overwrite the other with meaningless class references because they are environment classloader specific. I'd rather this was something like:

setEnvironmenDefault(Environment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we can have multiple servers in the same environment and each will have a different set of default configurations. So I think they still are server defaults

}
}

protected AbstractConfiguration(Builder builder)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit of a weird builder pattern. Normally you don't construct the object by passing it a builder, you use the builder to construct the object. Can't these fields just be protected final blank in AbstractConfiguration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a little different, but I don't think it can be miss-used, so I think it is OK.

@@ -605,7 +597,7 @@ public void postConfigure(WebAppContext context) throws Exception
* @throws IOException if unable to scan the directory
*/
// TODO: Needs to use resource.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe remove this TODO?

protected final List<DiscoveredServletContainerInitializerHolder> _sciHolders = new ArrayList<>();

protected List<ParserTask> _parserTasks;
protected static class State
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a record ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was intended to do that, but I'd need to make all fields final, which is a bit of work that risks changing behaviour.

}

@Override
public void configure(WebAppContext context) throws Exception
{
State state = (State)context.getAttribute(STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

ISE if state is null?

_classInheritanceHandler = null;
_containerInitializerAnnotationHandlers.clear();
_sciHolders.clear();
State state = (State)context.removeAttribute(STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

ISE if state is null?

@gregw gregw requested a review from janbartel May 12, 2023 10:54
@gregw gregw merged commit 4b67abc into jetty-12.0.x May 13, 2023
gregw added a commit that referenced this pull request May 13, 2023
updates from review
@joakime joakime deleted the jetty-12-immutable-ee10-configurations branch August 7, 2023 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants