Skip to content

Commit 54bae27

Browse files
Update Jetty version to 12.1.0.alpha2 for testing
Signed-off-by: Lachlan Roberts <[email protected]>
1 parent a5603d9 commit 54bae27

File tree

8 files changed

+53
-46
lines changed

8 files changed

+53
-46
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<maven.compiler.target>1.8</maven.compiler.target>
6666
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6767
<jetty.version>9.4.57.v20241219</jetty.version>
68-
<jetty12.version>12.0.18</jetty12.version>
68+
<jetty12.version>12.1.0.alpha2</jetty12.version>
6969
<io.grpc>1.71.0</io.grpc>
7070
<io.netty>4.1.119.Final</io.netty>
7171
<slf4j.version>2.0.17</slf4j.version>

runtime/local_jetty12/src/main/java/com/google/appengine/tools/development/jetty/JettyContainerService.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.ArrayList;
5050
import java.util.Collections;
5151
import java.util.List;
52+
import java.util.Map;
5253
import java.util.Set;
5354
import java.util.concurrent.ConcurrentHashMap;
5455
import java.util.concurrent.Semaphore;
@@ -509,9 +510,12 @@ private void fullWebAppScanner(int interval) throws IOException {
509510
scanner.setReportExistingFilesOnStartup(false);
510511
scanner.setScanDepth(3);
511512

512-
scanner.addListener((Scanner.BulkListener) filenames -> {
513-
log.info("A file has changed, reloading the web application.");
514-
reloadWebApp();
513+
scanner.addListener(new Scanner.BulkListener() {
514+
@Override
515+
public void pathsChanged(Map<Path, Scanner.Notification> changeSet) throws Exception {
516+
log.info("A file has changed, reloading the web application.");
517+
reloadWebApp();
518+
}
515519
});
516520

517521
LifeCycle.start(scanner);

runtime/local_jetty12_ee10/src/main/java/com/google/appengine/tools/development/jetty/ee10/JettyContainerService.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
import java.util.ArrayList;
5555
import java.util.Collections;
5656
import java.util.List;
57+
import java.util.Map;
5758
import java.util.Set;
5859
import java.util.concurrent.ConcurrentHashMap;
5960
import java.util.concurrent.Semaphore;
60-
import java.util.concurrent.TimeUnit;
6161
import java.util.logging.Level;
6262
import java.util.logging.Logger;
6363
import java.util.regex.Pattern;
@@ -517,9 +517,12 @@ private void fullWebAppScanner(int interval) throws IOException {
517517
scanner.setReportExistingFilesOnStartup(false);
518518
scanner.setScanDepth(3);
519519

520-
scanner.addListener((Scanner.BulkListener) filenames -> {
521-
log.info("A file has changed, reloading the web application.");
522-
reloadWebApp();
520+
scanner.addListener(new Scanner.BulkListener() {
521+
@Override
522+
public void pathsChanged(Map<Path, Scanner.Notification> changeSet) throws Exception {
523+
log.info("A file has changed, reloading the web application.");
524+
reloadWebApp();
525+
}
523526
});
524527

525528
LifeCycle.start(scanner);

runtime/runtime_impl_jetty12/pom.xml

+16
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@
121121
<version>${jetty12.version}</version>
122122
<type>jar</type>
123123
</dependency>
124+
<dependency>
125+
<groupId>org.eclipse.jetty.compression</groupId>
126+
<artifactId>jetty-compression-common</artifactId>
127+
<optional>true</optional>
128+
<version>${jetty12.version}</version>
129+
<type>jar</type>
130+
</dependency>
131+
<dependency>
132+
<groupId>org.eclipse.jetty.compression</groupId>
133+
<artifactId>jetty-compression-gzip</artifactId>
134+
<optional>true</optional>
135+
<version>${jetty12.version}</version>
136+
<type>jar</type>
137+
</dependency>
124138
<dependency>
125139
<groupId>org.eclipse.jetty.ee8</groupId>
126140
<artifactId>jetty-ee8-quickstart</artifactId>
@@ -572,6 +586,8 @@
572586
<include>org.eclipse.jetty:jetty-server</include>
573587
<include>org.eclipse.jetty:jetty-session</include>
574588
<include>org.eclipse.jetty:jetty-security</include>
589+
<include>org.eclipse.jetty.compression:jetty-compression-common</include>
590+
<include>org.eclipse.jetty.compression:jetty-compression-gzip</include>
575591
<include>org.slf4j:slf4j-jdk14</include>
576592
<include>org.slf4j:slf4j-api</include>
577593
<include>org.eclipse.jetty:jetty-util-ajax</include>

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/impl/ContentChunk.java

+3-31
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,15 @@
1717
package com.google.apphosting.runtime.jetty.delegate.impl;
1818

1919
import java.nio.ByteBuffer;
20-
import java.util.Objects;
21-
22-
import org.eclipse.jetty.io.Content;
23-
import org.eclipse.jetty.io.Retainable;
20+
import org.eclipse.jetty.io.internal.ByteBufferChunk;
2421
import org.eclipse.jetty.util.BufferUtil;
2522

26-
public class ContentChunk extends Retainable.ReferenceCounter implements Content.Chunk {
27-
private final ByteBuffer byteBuffer;
28-
private final boolean last;
29-
23+
public class ContentChunk extends ByteBufferChunk.WithReferenceCount {
3024
public ContentChunk(byte[] bytes) {
3125
this(BufferUtil.toBuffer(bytes), true);
3226
}
3327

3428
public ContentChunk(ByteBuffer byteBuffer, boolean last) {
35-
this.byteBuffer = Objects.requireNonNull(byteBuffer);
36-
this.last = last;
37-
}
38-
39-
@Override
40-
public ByteBuffer getByteBuffer() {
41-
return byteBuffer;
42-
}
43-
44-
@Override
45-
public boolean isLast() {
46-
return last;
47-
}
48-
49-
@Override
50-
public String toString() {
51-
52-
return String.format(
53-
"%s@%x[l=%b,b=%s]",
54-
getClass().getSimpleName(),
55-
hashCode(),
56-
isLast(),
57-
BufferUtil.toDetailString(getByteBuffer()));
29+
super(byteBuffer, last);
5830
}
5931
}

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/impl/DelegateRpcExchange.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import java.util.concurrent.atomic.AtomicReference;
3434
import org.eclipse.jetty.http.HttpFields;
3535
import org.eclipse.jetty.http.HttpMethod;
36-
import org.eclipse.jetty.io.ByteBufferAccumulator;
3736
import org.eclipse.jetty.io.Content;
37+
import org.eclipse.jetty.io.RetainableByteBuffer;
3838
import org.eclipse.jetty.util.Attributes;
3939
import org.eclipse.jetty.util.Callback;
4040

@@ -46,7 +46,7 @@ public class DelegateRpcExchange implements DelegateExchange {
4646
private final HttpPb.HttpRequest _request;
4747
private final AtomicReference<Content.Chunk> _content = new AtomicReference<>();
4848
private final MutableUpResponse _response;
49-
private final ByteBufferAccumulator accumulator = new ByteBufferAccumulator();
49+
private final RetainableByteBuffer.DynamicCapacity accumulator = new RetainableByteBuffer.DynamicCapacity();
5050
private final CompletableFuture<Void> _completion = new CompletableFuture<>();
5151
private final Attributes _attributes = new Attributes.Lazy();
5252
private final String _httpMethod;
@@ -158,13 +158,15 @@ public void addHeader(String name, String value) {
158158

159159
@Override
160160
public void write(boolean last, ByteBuffer content, Callback callback) {
161-
if (content != null) accumulator.copyBuffer(content);
161+
if (content != null) {
162+
accumulator.append(content);
163+
}
162164
callback.succeeded();
163165
}
164166

165167
@Override
166168
public void succeeded() {
167-
_response.setHttpResponseResponse(ByteString.copyFrom(accumulator.takeByteBuffer()));
169+
_response.setHttpResponseResponse(ByteString.copyFrom(accumulator.takeByteArray()));
168170
_response.setError(RuntimePb.UPResponse.ERROR.OK_VALUE);
169171
_completion.complete(null);
170172
}

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/internal/DelegateEndpoint.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import com.google.apphosting.runtime.jetty.delegate.api.DelegateExchange;
2020
import java.io.IOException;
21-
import java.net.InetSocketAddress;
21+
import java.net.SocketAddress;
2222
import java.nio.ByteBuffer;
2323
import java.nio.channels.ReadPendingException;
2424
import java.nio.channels.WritePendingException;
@@ -40,12 +40,12 @@ public DelegateExchange getDelegateExchange() {
4040
}
4141

4242
@Override
43-
public InetSocketAddress getLocalAddress() {
43+
public SocketAddress getLocalSocketAddress() {
4444
return _exchange.getLocalAddr();
4545
}
4646

4747
@Override
48-
public InetSocketAddress getRemoteAddress() {
48+
public SocketAddress getRemoteSocketAddress() {
4949
return _exchange.getRemoteAddr();
5050
}
5151

@@ -121,6 +121,11 @@ public boolean isFillInterested() {
121121
@Override
122122
public void write(Callback callback, ByteBuffer... buffers) throws WritePendingException {}
123123

124+
@Override
125+
public Callback cancelWrite(Throwable throwable) {
126+
return null;
127+
}
128+
124129
@Override
125130
public Connection getConnection() {
126131
return null;

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/delegate/internal/DelegateHttpStream.java

+5
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public void send(
8888
delegateExchange.write(last, content, callback);
8989
}
9090

91+
@Override
92+
public Runnable cancelSend(Throwable throwable, Callback callback) {
93+
return null;
94+
}
95+
9196
@Override
9297
public void push(MetaData.Request request) {
9398
throw new UnsupportedOperationException("push not supported");

0 commit comments

Comments
 (0)