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

[WEJBHTTP-139] Final round of cleanup refactorings accross all modules #259

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9d631d7
[WEJBHTTP-139] Refactoring - moving static imports to the top of impo…
ropalka Nov 29, 2024
682a83f
[WEJBHTTP-139] Refactoring - moving ByteOutputs classes to common module
ropalka Nov 29, 2024
a8be101
[WEJBHTTP-139] Refactoring - making all ByteOutputs wrapping OutputSt…
ropalka Nov 29, 2024
3bfbb00
[WEJBHTTP-139] Refactoring - unify OutputStream variable names
ropalka Nov 29, 2024
357e420
[WEJBHTTP-139] Removing remaining deprecated methods & constructors
ropalka Nov 29, 2024
1dde42a
[WEJBHTTP-139] Refactoring - use HttpServerHelper utility method via …
ropalka Nov 29, 2024
85b5810
[WEJBHTTP-139] Refactoring - merge transaction/Utils , naming/Utils &…
ropalka Dec 5, 2024
c4208da
[WEJBHTTP-139] Refactoring - merge common/Utils & common/HttpMarshall…
ropalka Dec 5, 2024
d2c8137
[WEJBHTTP-139] Refactoring - unify parameter names in Serializers
ropalka Dec 6, 2024
11abf95
[WEJBHTTP-139] Refactoring - unify parameter names in ClientHandlers
ropalka Dec 6, 2024
424ce0e
[WEJBHTTP-139] Refactoring - Introducing ByteInputs utility class
ropalka Dec 6, 2024
4509263
[WEJBHTTP-139] Refactoring - renaming httpServiceConfig variable to c…
ropalka Dec 6, 2024
1585469
[WEJBHTTP-139] Removing unused HttpRemoteEjbService.cancellationFlags…
ropalka Dec 6, 2024
c526cb3
[WEJBHTTP-139] Refactoring - reordering method parameters - let HttpS…
ropalka Dec 6, 2024
f47e24c
[WEJBHTTP-139] Refactoring - be consistent and always use HeaderMap.p…
ropalka Dec 10, 2024
9b3515d
[WEJBHTTP-139] Refactoring - Use Headers fields via static imports
ropalka Dec 10, 2024
b1f577d
[WEJBHTTP-139] Refactoring - Use StatusCodes fields via static imports
ropalka Dec 10, 2024
35e8968
[WEJBHTTP-139] Refactoring - always use HeadersHelper methods for bet…
ropalka Dec 10, 2024
3a7d2b8
[WEJBHTTP-139] Refactoring - Enhance HeadersHelper methods to enhance…
ropalka Dec 10, 2024
50ba294
[WEJBHTTP-139] Refactoring - use parseBoolean via static import
ropalka Dec 10, 2024
928e111
[WEJBHTTP-139] Refactoring - introducing OPC query parameter constant
ropalka Dec 10, 2024
0d91d27
[WEJBHTTP-139] Refactoring - use NEW_QUERY_PARAMETER constant
ropalka Dec 10, 2024
1b4f665
[WEJBHTTP-139] Refactoring - unify ClientRequest variable names
ropalka Dec 10, 2024
b1e7ff3
[WEJBHTTP-139] Refactoring - unify ClientResponse variable names
ropalka Dec 10, 2024
bd13773
[WEJBHTTP-139] Refactoring - use EJB_SESSION_ID via static import
ropalka Dec 10, 2024
43d0acd
[WEJBHTTP-139] Enhancement according to peer review - always throw Il…
ropalka Jan 16, 2025
32c4a0e
[WEJBHTTP-139] Enhancement according to peer review - use 'input' and…
ropalka Jan 16, 2025
b79131a
[WEJBHTTP-139] Enhancement according to peer review - don't use Objec…
ropalka Jan 16, 2025
41b44a2
[WEJBHTTP-139] Enhancement according to peer review - use txnInfo ins…
ropalka Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import java.io.OutputStream;

/**
* Helper class. Provides utility method for transforming OutputStreams to ByteOutputs.
* Helper class. Provides various utility methods for example:
* <ul>
* <li>transforming OutputStreams to ByteOutputs</li>
* <li>introducing special behaviour to existing byte output instances</li>
* </ul>
*
* @author <a href="mailto:[email protected]">Richard Opalka</a>
*/
Expand All @@ -35,7 +39,7 @@ private ByteOutputs() {

public static ByteOutput byteOutputOf(final OutputStream delegate) {
if (delegate == null) throw new IllegalArgumentException();
return new ByteOutputStream(delegate);
return new UnflushableByteOutput(new ByteOutputStream(delegate));
}

private static final class ByteOutputStream implements ByteOutput {
Expand Down Expand Up @@ -73,4 +77,38 @@ public void write(final byte[] b, final int off, final int len) throws IOExcepti

}

private static final class UnflushableByteOutput implements ByteOutput {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Motivation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is the way this protocol was implemented. Output is always sent at once to prevent fragmentation on the wire.
I maintained it for backward compatibility. For future version of the protocol we could revisit it if its really necessary.


private final ByteOutput delegate;

public UnflushableByteOutput(final ByteOutput delegate) {
this.delegate = delegate;
}

@Override
public void close() throws IOException {
delegate.close();
}

@Override
public void flush() throws IOException {
//ignore
}
@Override
public void write(final int b) throws IOException {
delegate.write(b);
}

@Override
public void write(final byte[] b) throws IOException {
delegate.write(b);
}

@Override
public void write(final byte[] b, int off, int len) throws IOException {
delegate.write(b, off, len);
}

}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.wildfly.httpclient.common.HttpMarshallerFactory;
import org.wildfly.httpclient.common.HttpServerHelper;
import org.wildfly.httpclient.common.HttpServiceConfig;
import org.wildfly.httpclient.common.NoFlushByteOutput;

import javax.naming.Binding;
import javax.naming.Context;
Expand Down Expand Up @@ -134,7 +133,7 @@ public final void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, VALUE.toString());
HttpNamingServerObjectResolver resolver = new HttpNamingServerObjectResolver(exchange);
Marshaller marshaller = config.getHttpMarshallerFactory(exchange).createMarshaller(resolver);
ByteOutput out = new NoFlushByteOutput(byteOutputOf(exchange.getOutputStream()));
ByteOutput out = byteOutputOf(exchange.getOutputStream());
try (out) {
marshaller.start(out);
serializeObject(marshaller, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.jboss.marshalling.Marshaller;
import org.jboss.marshalling.Unmarshaller;
import org.wildfly.httpclient.common.HttpTargetContext;
import org.wildfly.httpclient.common.NoFlushByteOutput;
import org.xnio.IoUtils;

import javax.transaction.xa.Xid;
Expand Down Expand Up @@ -77,7 +76,7 @@ private XidHttpMarshaller(final Marshaller marshaller, final Xid xid) {

@Override
public void marshall(final OutputStream httpBodyRequestStream) throws Exception {
try (ByteOutput out = new NoFlushByteOutput(byteOutputOf(httpBodyRequestStream))) {
try (ByteOutput out = byteOutputOf(httpBodyRequestStream)) {
marshaller.start(out);
serializeXid(marshaller, xid);
marshaller.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.wildfly.httpclient.common.ContentType;
import org.wildfly.httpclient.common.HttpMarshallerFactory;
import org.wildfly.httpclient.common.HttpServiceConfig;
import org.wildfly.httpclient.common.NoFlushByteOutput;
import org.wildfly.transaction.client.ImportResult;
import org.wildfly.transaction.client.LocalTransaction;
import org.wildfly.transaction.client.LocalTransactionContext;
Expand Down Expand Up @@ -192,7 +191,7 @@ protected void processRequest(final HttpServerExchange exchange) {
final Xid xid = xidResolver.apply(transaction);

final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ByteOutput byteOutput = new NoFlushByteOutput(byteOutputOf(out));
final ByteOutput byteOutput = byteOutputOf(out);
try (byteOutput) {
Marshaller marshaller = config.getHttpMarshallerFactory(exchange).createMarshaller();
marshaller.start(byteOutput);
Expand Down Expand Up @@ -237,7 +236,7 @@ protected void processRequest(HttpServerExchange exchange) {
final Xid[] recoveryList = ctx.getRecoveryInterface().recover(flags, parentName);

final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ByteOutput byteOutput = new NoFlushByteOutput(byteOutputOf(out));
final ByteOutput byteOutput = byteOutputOf(out);
try (byteOutput) {
Marshaller marshaller = config.getHttpMarshallerFactory(exchange).createMarshaller();
marshaller.start(byteOutput);
Expand Down