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

Merge 2.1.x into 2.x #892

Merged
merged 27 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5ad705f
Better Support deployment handshake statuses != 101
jansupol Dec 13, 2023
ee87803
Merge remote-tracking branch 'master' into `2.0.x`
jansupol Dec 19, 2023
1a83c0d
Build Tyrus on JDK 17
jansupol Dec 20, 2023
e64196d
Merge remote-tracking branch 'master' into '2.0.x'
jansupol Dec 21, 2023
3a3cbb2
Support JDK 7
jansupol Dec 19, 2023
a7d06f5
Merge pull request #877 from jansupol/1.x.m5
jansupol Dec 21, 2023
baddff9
Merge remote-tracking branch 'MSTR/master' into 1x.m6
jansupol Dec 21, 2023
0ad61a8
Revert the JDK7-related changes for EE9+ branch
jansupol Dec 21, 2023
7163cb0
Updated copyright year
jansupol Jan 5, 2024
391cb44
Merge pull request #878 from jansupol/1x.m6
jansupol Jan 5, 2024
dcf9286
Support user-defined reason phrase
jansupol Jan 4, 2024
f89bed6
Merge remote-tracking branch 'master' into '2.0.x'
jansupol Jan 5, 2024
34ac53f
Merge pull request #880 from jansupol/1x.m7
jansupol Jan 5, 2024
8fa17d2
Merge remote-tracking branch 2.0.x into 2.1.x
jansupol Jan 5, 2024
e02b481
Updated copyright year
jansupol Jan 5, 2024
64b74b7
Merge pull request #881 from jansupol/20.m1
jansupol Jan 8, 2024
587cf80
Prepare release org.glassfish.tyrus:tyrus-project:2.0.6
tyrus-bot Jan 9, 2024
1ab7ce7
Prepare next development cycle for 2.0.99-SNAPSHOT
tyrus-bot Jan 9, 2024
54103e0
Merge pull request #884 from eclipse-ee4j/2.0.6-BRANCH
jansupol Jan 10, 2024
ce41152
Adopt new Grizzly 4.0.2
jansupol Jan 8, 2024
fa843e8
Prepare release org.glassfish.tyrus:tyrus-project:2.1.5
tyrus-bot Jan 17, 2024
20c6941
Prepare next development cycle for 2.1.99-SNAPSHOT
tyrus-bot Jan 17, 2024
98ac834
Merge pull request #886 from eclipse-ee4j/2.1.5-BRANCH
jansupol Jan 18, 2024
4c70258
Fix OSGi export for Tyrus Client (#890)
jansupol Jan 31, 2024
444b8b8
Merge remote-tracking branch 'MSTR/2.0.x' into fix.client.osgi.21
jansupol Jan 31, 2024
fd1e9ea
Merge pull request #891 from jansupol/fix.client.osgi.21
jansupol Jan 31, 2024
ba325a0
Merge branch 2.1.x into 2.x
jansupol Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ for easy development of WebSocket applications.Eclipse Tyrus is also
a Jakarta WebSocket 2.0 compatible implementation.

WebSocket protocol defined by IETF
provides bi-directional communication between the server and the remote host. The
provides bidirectional communication between the server and the remote host. The
pros are mainly the ability to communicate both ways, low latency and small
communication overhead. Therefore Tyrus and WebSocket in general are suitable for web
communication overhead. Therefore, Tyrus and WebSocket in general are suitable for web
applications that require sending a huge volume of relatively small messages like
online games or market ticker broadcasting.

Expand All @@ -23,6 +23,15 @@ This is Jakarta EE 11 / Jakarta WebSocket 2.2.0 compatible branch of Tyrus
Building Tyrus can be done using `mvn clean install`, but sometimes (such as for building 2.x from a tag)
`mvn clean install -Pstaging` would be required.

## Tyrus Git Branches

| branch | Jakarta Version | Tyrus Version |
|--------|---------------------------------|---------------|
| master | Java EE 8 / Jakarta EE 8 branch | Tyrus 1.x |
| 2.0.x | Jakarta EE 9 branch | Tyrus 2.0.x |
| 2.1.x | Jakarta EE 10 branch | Tyrus 2.1.x |
| 2.x | Jakarta EE 11 branch | Tyrus 2.2.x |

## Licensing

- [Eclipse Public License 2.0](https://projects.eclipse.org/license/epl-2.0)
Expand Down
2 changes: 1 addition & 1 deletion archetypes/echo/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2014, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion archetypes/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/client-jdk/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--

Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/client/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--

Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/samples/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/websocket-ri-archive/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/websocket-ri-bundle/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
6 changes: 1 addition & 5 deletions client/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--

Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2024 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -54,10 +54,6 @@
<inherited>true</inherited>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.glassfish.tyrus.client;version=${project.version}</Export-Package>
<!-- <Import-Package>jakarta.websocket;version=${apijar.bundle.version},*</Import-Package>-->
</instructions>
<unpackBundle>true</unpackBundle>
</configuration>
</plugin>
Expand Down
3 changes: 2 additions & 1 deletion client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -26,4 +26,5 @@

exports org.glassfish.tyrus.client;
exports org.glassfish.tyrus.client.auth;
exports org.glassfish.tyrus.client.exception;
}
83 changes: 22 additions & 61 deletions client/src/main/java/org/glassfish/tyrus/client/ClientManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -42,6 +42,7 @@
import jakarta.websocket.Session;
import jakarta.websocket.WebSocketContainer;

import org.glassfish.tyrus.client.exception.Exceptions;
import org.glassfish.tyrus.core.AnnotatedEndpoint;
import org.glassfish.tyrus.core.BaseContainer;
import org.glassfish.tyrus.core.ComponentProviderService;
Expand All @@ -52,6 +53,7 @@
import org.glassfish.tyrus.core.TyrusFuture;
import org.glassfish.tyrus.core.TyrusSession;
import org.glassfish.tyrus.core.Utils;
import org.glassfish.tyrus.core.collection.SupplierWithEx;
import org.glassfish.tyrus.core.monitoring.EndpointEventListener;
import org.glassfish.tyrus.spi.ClientContainer;
import org.glassfish.tyrus.spi.ClientEngine;
Expand Down Expand Up @@ -288,81 +290,46 @@ public boolean evaluate() {
}

@Override
public Session connectToServer(Class annotatedEndpointClass, URI path) throws DeploymentException, IOException {
public Session connectToServer(final Class annotatedEndpointClass, final URI path) throws DeploymentException, IOException {
if (annotatedEndpointClass.getAnnotation(ClientEndpoint.class) == null) {
throw new DeploymentException(
String.format(
"Class argument in connectToServer(Class, URI) is to be annotated endpoint class. Class "
+ "%s does not have @ClientEndpoint", annotatedEndpointClass.getName()));
}
try {
return connectToServer(annotatedEndpointClass, null, path.toString(), true).get();
} catch (InterruptedException e) {
throw new DeploymentException(e.getMessage(), e);
} catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof DeploymentException) {
throw (DeploymentException) cause;
} else if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new DeploymentException(cause.getMessage(), cause);
}
}
return tryCatchInterruptedExecutionEx(() -> connectToServer(annotatedEndpointClass, null, path.toString(), true));
}

@Override
public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws
DeploymentException, IOException {
try {
return connectToServer(endpointClass, cec, path.toString(), true).get();
} catch (InterruptedException e) {
throw new DeploymentException(e.getMessage(), e);
} catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof DeploymentException) {
throw (DeploymentException) cause;
} else if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new DeploymentException(cause.getMessage(), cause);
}
}
public Session connectToServer(final Class<? extends Endpoint> endpointClass,
final ClientEndpointConfig cec,
final URI path) throws DeploymentException, IOException {
return tryCatchInterruptedExecutionEx(() -> connectToServer(endpointClass, cec, path.toString(), true));
}

@Override
public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws
public Session connectToServer(final Endpoint endpointInstance, final ClientEndpointConfig cec, final URI path) throws
DeploymentException, IOException {
try {
return connectToServer(endpointInstance, cec, path.toString(), true).get();
} catch (InterruptedException e) {
throw new DeploymentException(e.getMessage(), e);
} catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof DeploymentException) {
throw (DeploymentException) cause;
} else if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new DeploymentException(cause.getMessage(), cause);
}
}
return tryCatchInterruptedExecutionEx(() -> connectToServer(endpointInstance, cec, path.toString(), true));
}

@Override
public Session connectToServer(Object obj, URI path) throws DeploymentException, IOException {
public Session connectToServer(final Object obj, final URI path) throws DeploymentException, IOException {
return tryCatchInterruptedExecutionEx(() -> connectToServer(obj, null, path.toString(), true));
}

private Session tryCatchInterruptedExecutionEx(SupplierWithEx<Future<Session>, DeploymentException> supplier)
throws DeploymentException, IOException {
try {
return connectToServer(obj, null, path.toString(), true).get();
return supplier.get().get();
} catch (InterruptedException e) {
throw new DeploymentException(e.getMessage(), e);
} catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof DeploymentException) {
throw (DeploymentException) cause;
} else if (cause instanceof IOException) {
if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new DeploymentException(cause.getMessage(), cause);
throw Exceptions.deploymentException(cause.getMessage(), cause);
}
}
}
Expand Down Expand Up @@ -652,11 +619,7 @@ public void onClose(TyrusSession session,
if (countedDown) {
final Throwable exception = listener.getThrowable();
if (exception != null) {
if (exception instanceof DeploymentException) {
throw (DeploymentException) exception;
} else {
throw new DeploymentException("Handshake error.", exception);
}
throw Exceptions.deploymentException("Handshake error.", exception);
}

future.setResult(listener.getSession());
Expand All @@ -669,10 +632,8 @@ public void onClose(TyrusSession session,
timeoutHandler.handleTimeout();
}
}
} catch (DeploymentException e) {
throw e;
} catch (Exception e) {
throw new DeploymentException("Handshake response not received.", e);
throw Exceptions.deploymentException("Handshake response not received.", e);
}

throw new DeploymentException("Handshake response not received.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -65,6 +65,7 @@
import org.glassfish.tyrus.spi.ClientEngine;
import org.glassfish.tyrus.spi.Connection;
import org.glassfish.tyrus.spi.ReadHandler;
import org.glassfish.tyrus.spi.TyrusClientEndpointConfigurator;
import org.glassfish.tyrus.spi.UpgradeRequest;
import org.glassfish.tyrus.spi.UpgradeResponse;
import org.glassfish.tyrus.spi.Writer;
Expand Down Expand Up @@ -169,6 +170,9 @@ public UpgradeRequest createUpgradeRequest(TimeoutHandler timeoutHandler) {
clientHandShake.prepareRequest();

UpgradeRequest upgradeRequest = clientHandShake.getRequest();
if (TyrusClientEndpointConfigurator.class.isInstance(config.getConfigurator())) {
((TyrusClientEndpointConfigurator) config.getConfigurator()).beforeRequest(upgradeRequest);
}
config.getConfigurator().beforeRequest(upgradeRequest.getHeaders());

clientEngineState = TyrusClientEngineState.UPGRADE_REQUEST_CREATED;
Expand Down Expand Up @@ -251,6 +255,7 @@ public ClientUpgradeInfo processResponse(final UpgradeResponse upgradeResponse,
throw new IllegalArgumentException(LocalizationMessages.ARGUMENT_NOT_NULL("upgradeResponse"));
}

final ClientEngine.ClientUpgradeInfo upgradeInfo;
switch (upgradeResponse.getStatus()) {
case 101:
return handleSwitchProtocol(upgradeResponse, writer, closeListener);
Expand All @@ -262,7 +267,8 @@ public ClientUpgradeInfo processResponse(final UpgradeResponse upgradeResponse,
case 308:
return handleRedirect(upgradeResponse);
case 401:
return handleAuth(upgradeResponse);
upgradeInfo = handleAuth(upgradeResponse);
break;
case 503:

// get Retry-After header
Expand Down Expand Up @@ -293,19 +299,21 @@ public ClientUpgradeInfo processResponse(final UpgradeResponse upgradeResponse,

listener.onError(new RetryAfterException(
LocalizationMessages.HANDSHAKE_HTTP_RETRY_AFTER_MESSAGE(), delay));
return UPGRADE_INFO_FAILED;
upgradeInfo = UPGRADE_INFO_FAILED;
break;
default:
((ClientEndpointConfig) endpointWrapper.getEndpointConfig()).getConfigurator().afterResponse(upgradeResponse);

clientEngineState = TyrusClientEngineState.FAILED;
HandshakeException e = new HandshakeException(
upgradeResponse.getStatus(),
LocalizationMessages.INVALID_RESPONSE_CODE(101, upgradeResponse.getStatus()));
listener.onError(e);
redirectUriHistory.clear();
return UPGRADE_INFO_FAILED;
upgradeInfo = UPGRADE_INFO_FAILED;
break;
}

((ClientEndpointConfig) endpointWrapper.getEndpointConfig()).getConfigurator().afterResponse(upgradeResponse);
return upgradeInfo;
}

redirectUriHistory.clear();
Expand Down
Loading
Loading