Skip to content

Commit 927daaa

Browse files
committed
Avoid having part of the methods static and the other part instance
While this is a breaking change, I had a look at the impact in the Ecosystem and it looks like it wouldn't break too many components.
1 parent c915015 commit 927daaa

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

core/runtime/src/main/java/io/quarkus/runtime/LaunchMode.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ public enum LaunchMode {
2424
public static final String PROD_PROFILE = "prod";
2525
public static final String TEST_PROFILE = "test";
2626

27-
public static boolean isDev() {
28-
return current() == DEVELOPMENT;
29-
}
30-
31-
/**
32-
* Returns true if the current launch is the server side of remote dev.
33-
*/
34-
public static boolean isRemoteDev() {
35-
return (current() == DEVELOPMENT) && "true".equals(System.getenv("QUARKUS_LAUNCH_DEVMODE"));
36-
}
37-
3827
private final String defaultProfile;
3928
private final String profileKey;
4029
private final boolean devServicesSupported;
@@ -56,6 +45,17 @@ public String getProfileKey() {
5645
return profileKey;
5746
}
5847

48+
public boolean isDev() {
49+
return this == DEVELOPMENT;
50+
}
51+
52+
/**
53+
* Returns true if the current launch is the server side of remote dev.
54+
*/
55+
public boolean isRemoteDev() {
56+
return (this == DEVELOPMENT) && "true".equals(System.getenv("QUARKUS_LAUNCH_DEVMODE"));
57+
}
58+
5959
public boolean isDevOrTest() {
6060
return this == DEVELOPMENT || this == TEST;
6161
}

extensions/agroal/runtime-dev/src/main/java/io/quarkus/agroal/runtime/dev/ui/DatabaseInspector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public final class DatabaseInspector {
5252

5353
public DatabaseInspector() {
5454
LaunchMode currentMode = LaunchMode.current();
55-
this.isDev = currentMode == LaunchMode.DEVELOPMENT && !LaunchMode.isRemoteDev();
55+
this.isDev = currentMode.isDev() && !currentMode.isRemoteDev();
5656

5757
Config config = ConfigProvider.getConfig();
5858
this.allowSql = config.getOptionalValue("quarkus.datasource.dev-ui.allow-sql", Boolean.class)

extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dev/HibernateOrmDevJsonRpcService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class HibernateOrmDevJsonRpcService {
3636
private String allowedHost;
3737

3838
public HibernateOrmDevJsonRpcService() {
39-
this.isDev = LaunchMode.current() == LaunchMode.DEVELOPMENT && !LaunchMode.isRemoteDev();
39+
this.isDev = LaunchMode.current().isDev() && !LaunchMode.current().isRemoteDev();
4040
this.allowedHost = ConfigProvider.getConfig()
4141
.getOptionalValue("quarkus.datasource.dev-ui.allowed-db-host", String.class)
4242
.orElse(null);

extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/AuthenticationCompletionExceptionMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class AuthenticationCompletionExceptionMapper implements ExceptionMapper<
1717
@Override
1818
public Response toResponse(AuthenticationCompletionException ex) {
1919
log.debug("Authentication has failed, returning HTTP status 401");
20-
if (LaunchMode.isDev() && ex.getMessage() != null) {
20+
if (LaunchMode.current().isDev() && ex.getMessage() != null) {
2121
return Response.status(401).entity(ex.getMessage()).build();
2222
}
2323
return Response.status(401).build();

extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/AuthenticationFailedExceptionMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Response toResponse(AuthenticationFailedException exception) {
4545
if (challengeData != null && challengeData.headerName != null) {
4646
responseBuilder.header(challengeData.headerName.toString(), challengeData.headerContent);
4747
}
48-
if (LaunchMode.isDev() && exception.getMessage() != null && statusCode == 401) {
48+
if (LaunchMode.current().isDev() && exception.getMessage() != null && statusCode == 401) {
4949
responseBuilder.entity(exception.getMessage());
5050
}
5151
log.debugf("Returning an authentication challenge, status code: %d", statusCode);
@@ -56,7 +56,7 @@ public Response toResponse(AuthenticationFailedException exception) {
5656
} else {
5757
log.error("RoutingContext is not found, returning HTTP status 401");
5858
}
59-
if (LaunchMode.isDev() && exception.getMessage() != null) {
59+
if (LaunchMode.current().isDev() && exception.getMessage() != null) {
6060
return Response.status(401).entity(exception.getMessage()).build();
6161
}
6262
return Response.status(401).entity("Not Authenticated").build();

extensions/resteasy-reactive/rest/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/exceptionmappers/AuthenticationCompletionExceptionMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class AuthenticationCompletionExceptionMapper implements ExceptionMapper<
1010

1111
@Override
1212
public Response toResponse(AuthenticationCompletionException ex) {
13-
if (LaunchMode.isDev() && ex.getMessage() != null) {
13+
if (LaunchMode.current().isDev() && ex.getMessage() != null) {
1414
return Response.status(Response.Status.UNAUTHORIZED).entity(ex.getMessage()).build();
1515
}
1616
return Response.status(Response.Status.UNAUTHORIZED).build();

extensions/resteasy-reactive/rest/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/exceptionmappers/AuthenticationFailedExceptionMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public class AuthenticationFailedExceptionMapper {
1818
public Uni<Response> handle(RoutingContext routingContext, AuthenticationFailedException exception) {
1919
addAuthenticationFailureToEvent(exception, routingContext);
2020
return SecurityExceptionMapperUtil.handleWithAuthenticator(routingContext,
21-
LaunchMode.isDev() ? exception.getMessage() : null);
21+
LaunchMode.current().isDev() ? exception.getMessage() : null);
2222
}
2323
}

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void accept(Throwable throwable) {
124124
if ((exception instanceof AuthenticationCompletionException
125125
|| (exception instanceof AuthenticationFailedException && event.response().getStatusCode() == 401))
126126
&& exception.getMessage() != null
127-
&& LaunchMode.isDev()) {
127+
&& LaunchMode.current().isDev()) {
128128
event.response().end(exception.getMessage());
129129
} else {
130130
event.response().end();

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxConfigBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static void defineHttpInterface(SmallRyeConfigBuilder builder, String co
2525
}
2626

2727
// Sets the default host config value, depending on the launch mode
28-
if (LaunchMode.isRemoteDev()) {
28+
if (LaunchMode.current().isRemoteDev()) {
2929
// in remote dev mode, we want to listen on all interfaces
3030
// to make sure the application is accessible
3131
builder.withDefaultValue(configurationProperty, ALL_INTERFACES);

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void accept(RoutingContext event, Throwable throwable) {
218218
return;
219219
}
220220
throwable = extractRootCause(throwable);
221-
if (LaunchMode.isDev() && throwable instanceof AuthenticationException
221+
if (LaunchMode.current().isDev() && throwable instanceof AuthenticationException
222222
&& throwable.getMessage() != null) {
223223
event.put(DEV_MODE_AUTHENTICATION_FAILURE_BODY, throwable.getMessage());
224224
}

0 commit comments

Comments
 (0)