Merge
This commit is contained in:
commit
1839997d4b
jdk
src
java.base/share/classes/java/nio
java.httpclient/share/classes/java/net/http
test
java/nio/Buffer
Order-X.java.templateOrder.javaOrderChar.javaOrderDouble.javaOrderFloat.javaOrderInt.javaOrderLong.javaOrderShort.java
javax/net/ssl/ServerName
sun/net/www/protocol/https/HttpsURLConnection
@ -111,7 +111,7 @@ import java.util.Spliterator;
|
||||
* to zero.
|
||||
*
|
||||
*
|
||||
* <h2> Clearing, flipping, and rewinding </h2>
|
||||
* <h2> Additional operations </h2>
|
||||
*
|
||||
* <p> In addition to methods for accessing the position, limit, and capacity
|
||||
* values and for marking and resetting, this class also defines the following
|
||||
@ -131,6 +131,12 @@ import java.util.Spliterator;
|
||||
* it already contains: It leaves the limit unchanged and sets the position
|
||||
* to zero. </p></li>
|
||||
*
|
||||
* <li><p> {@link #slice} creates a subsequence of a buffer: It leaves the
|
||||
* limit and the position unchanged. </p></li>
|
||||
*
|
||||
* <li><p> {@link #duplicate} creates a shallow copy of a buffer: It leaves
|
||||
* the limit and the position unchanged. </p></li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
@ -567,6 +573,46 @@ public abstract class Buffer {
|
||||
*/
|
||||
public abstract boolean isDirect();
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of
|
||||
* this buffer's content.
|
||||
*
|
||||
* <p> The content of the new buffer will start at this buffer's current
|
||||
* position. Changes to this buffer's content will be visible in the new
|
||||
* buffer, and vice versa; the two buffers' position, limit, and mark
|
||||
* values will be independent.
|
||||
*
|
||||
* <p> The new buffer's position will be zero, its capacity and its limit
|
||||
* will be the number of elements remaining in this buffer, its mark will be
|
||||
* undefined. The new buffer will be direct if, and only if, this buffer is
|
||||
* direct, and it will be read-only if, and only if, this buffer is
|
||||
* read-only. </p>
|
||||
*
|
||||
* @return The new buffer
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public abstract Buffer slice();
|
||||
|
||||
/**
|
||||
* Creates a new buffer that shares this buffer's content.
|
||||
*
|
||||
* <p> The content of the new buffer will be that of this buffer. Changes
|
||||
* to this buffer's content will be visible in the new buffer, and vice
|
||||
* versa; the two buffers' position, limit, and mark values will be
|
||||
* independent.
|
||||
*
|
||||
* <p> The new buffer's capacity, limit, position and mark values will be
|
||||
* identical to those of this buffer. The new buffer will be direct if, and
|
||||
* only if, this buffer is direct, and it will be read-only if, and only if,
|
||||
* this buffer is read-only. </p>
|
||||
*
|
||||
* @return The new buffer
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public abstract Buffer duplicate();
|
||||
|
||||
|
||||
// -- Package-private methods for bounds checking, etc. --
|
||||
|
||||
|
@ -70,8 +70,7 @@ import java.util.stream.$Streamtype$Stream;
|
||||
*
|
||||
#end[byte]
|
||||
*
|
||||
* <li><p> Methods for {@link #compact compacting}, {@link
|
||||
* #duplicate duplicating}, and {@link #slice slicing}
|
||||
* <li><p> A method for {@link #compact compacting}
|
||||
* $a$ $type$ buffer. </p></li>
|
||||
*
|
||||
* </ul>
|
||||
@ -535,6 +534,7 @@ public abstract class $Type$Buffer
|
||||
* @see #alignedSlice(int)
|
||||
#end[byte]
|
||||
*/
|
||||
@Override
|
||||
public abstract $Type$Buffer slice();
|
||||
|
||||
/**
|
||||
@ -557,6 +557,7 @@ public abstract class $Type$Buffer
|
||||
*
|
||||
* @return The new $type$ buffer
|
||||
*/
|
||||
@Override
|
||||
public abstract $Type$Buffer duplicate();
|
||||
|
||||
/**
|
||||
|
@ -35,6 +35,7 @@ import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -155,6 +156,15 @@ class HttpClientImpl extends HttpClient implements BufferHandler {
|
||||
selmgr.register(exchange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used from RawChannel to disconnect the channel from
|
||||
* the selector
|
||||
*/
|
||||
void cancelRegistration(SocketChannel s) {
|
||||
selmgr.cancel(s);
|
||||
}
|
||||
|
||||
|
||||
Http2ClientImpl client2() {
|
||||
return client2;
|
||||
}
|
||||
@ -220,6 +230,13 @@ class HttpClientImpl extends HttpClient implements BufferHandler {
|
||||
selector.wakeup();
|
||||
}
|
||||
|
||||
synchronized void cancel(SocketChannel e) {
|
||||
SelectionKey key = e.keyFor(selector);
|
||||
if (key != null)
|
||||
key.cancel();
|
||||
selector.wakeup();
|
||||
}
|
||||
|
||||
void wakeupSelector() {
|
||||
selector.wakeup();
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
*/
|
||||
|
||||
package java.net.http;
|
||||
|
||||
public interface HttpHeaders1 extends HttpHeaders {
|
||||
public void makeUnmodifiable();
|
||||
}
|
@ -176,7 +176,7 @@ class HttpResponseImpl extends HttpResponse {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
RawChannel rawChannel() {
|
||||
RawChannel rawChannel() throws IOException {
|
||||
if (rawchan == null) {
|
||||
rawchan = new RawChannel(request.client(), connection);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.nio.channels.ByteChannel;
|
||||
import java.nio.channels.GatheringByteChannel;
|
||||
import java.nio.channels.SelectableChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
//
|
||||
// Used to implement WebSocket. Each RawChannel corresponds to a TCP connection
|
||||
@ -56,9 +57,21 @@ final class RawChannel implements ByteChannel, GatheringByteChannel {
|
||||
interface NonBlockingEvent extends RawEvent {
|
||||
}
|
||||
|
||||
RawChannel(HttpClientImpl client, HttpConnection connection) {
|
||||
RawChannel(HttpClientImpl client, HttpConnection connection)
|
||||
throws IOException {
|
||||
this.client = client;
|
||||
this.connection = connection;
|
||||
SocketChannel chan = connection.channel();
|
||||
client.cancelRegistration(chan);
|
||||
chan.configureBlocking(false);
|
||||
}
|
||||
|
||||
SocketChannel socketChannel() {
|
||||
return connection.channel();
|
||||
}
|
||||
|
||||
ByteBuffer getRemaining() {
|
||||
return connection.getRemaining();
|
||||
}
|
||||
|
||||
private class RawAsyncEvent extends AsyncEvent {
|
||||
|
@ -24,6 +24,8 @@
|
||||
*/
|
||||
package java.net.http;
|
||||
|
||||
import java.io.UncheckedIOException;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -126,6 +128,8 @@ final class WSOpeningHandshake {
|
||||
return CompletableFuture.completedFuture(result);
|
||||
} catch (WebSocketHandshakeException e) {
|
||||
return CompletableFuture.failedFuture(e);
|
||||
} catch (UncheckedIOException ee) {
|
||||
return CompletableFuture.failedFuture(ee.getCause());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -149,7 +153,12 @@ final class WSOpeningHandshake {
|
||||
checkAccept(response, h);
|
||||
checkExtensions(response, h);
|
||||
String subprotocol = checkAndReturnSubprotocol(response, h);
|
||||
RawChannel channel = ((HttpResponseImpl) response).rawChannel();
|
||||
RawChannel channel = null;
|
||||
try {
|
||||
channel = ((HttpResponseImpl) response).rawChannel();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
return new Result(subprotocol, channel);
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,5 @@ public class Order$Type$ extends Order {
|
||||
buf = $Type$Buffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ck$Type$Buffer(buf, nord);
|
||||
|
||||
ck$Type$Buffer(ByteBuffer.allocate(LENGTH).as$Type$Buffer(), be);
|
||||
ck$Type$Buffer(ByteBuffer.allocateDirect(LENGTH).as$Type$Buffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -51,25 +51,31 @@ public class Order {
|
||||
ck(bb.asDoubleBuffer().order(), bb.order());
|
||||
}
|
||||
|
||||
private static void ckCopyViews(ByteBuffer bb) {
|
||||
ck(bb.asReadOnlyBuffer().order(), be);
|
||||
ck(bb.duplicate().order(), be);
|
||||
ck(bb.slice().order(), be);
|
||||
}
|
||||
|
||||
private static void ckByteBuffer(ByteBuffer bb) {
|
||||
ckViews(bb);
|
||||
ckCopyViews(bb);
|
||||
bb.order(be);
|
||||
ckViews(bb);
|
||||
ckCopyViews(bb);
|
||||
bb.order(le);
|
||||
ckViews(bb);
|
||||
|
||||
if (bb.hasArray()) {
|
||||
byte[] array = bb.array();
|
||||
ck(ByteBuffer.wrap(array, LENGTH/2, LENGTH/2).order(), be);
|
||||
ck(ByteBuffer.wrap(array).order(), be);
|
||||
ck(bb.asReadOnlyBuffer().order(), be);
|
||||
ck(bb.duplicate().order(), be);
|
||||
ck(bb.slice().order(), be);
|
||||
}
|
||||
ckCopyViews(bb);
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(), be);
|
||||
ck(ByteBuffer.wrap(new byte[LENGTH]).order(), be);
|
||||
ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(be).order(), be);
|
||||
ck(ByteBuffer.wrap(new byte[LENGTH]).order(be).order(), be);
|
||||
ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(le).order(), le);
|
||||
ck(ByteBuffer.wrap(new byte[LENGTH]).order(le).order(), le);
|
||||
ck(ByteBuffer.allocate(LENGTH).order(), be);
|
||||
ck(ByteBuffer.allocateDirect(LENGTH).order(), be);
|
||||
ck(ByteBuffer.allocate(LENGTH).order(be).order(), be);
|
||||
|
@ -52,8 +52,5 @@ public class OrderChar extends Order {
|
||||
buf = CharBuffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ckCharBuffer(buf, nord);
|
||||
|
||||
ckCharBuffer(ByteBuffer.allocate(LENGTH).asCharBuffer(), be);
|
||||
ckCharBuffer(ByteBuffer.allocateDirect(LENGTH).asCharBuffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,5 @@ public class OrderDouble extends Order {
|
||||
buf = DoubleBuffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ckDoubleBuffer(buf, nord);
|
||||
|
||||
ckDoubleBuffer(ByteBuffer.allocate(LENGTH).asDoubleBuffer(), be);
|
||||
ckDoubleBuffer(ByteBuffer.allocateDirect(LENGTH).asDoubleBuffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,5 @@ public class OrderFloat extends Order {
|
||||
buf = FloatBuffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ckFloatBuffer(buf, nord);
|
||||
|
||||
ckFloatBuffer(ByteBuffer.allocate(LENGTH).asFloatBuffer(), be);
|
||||
ckFloatBuffer(ByteBuffer.allocateDirect(LENGTH).asFloatBuffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,5 @@ public class OrderInt extends Order {
|
||||
buf = IntBuffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ckIntBuffer(buf, nord);
|
||||
|
||||
ckIntBuffer(ByteBuffer.allocate(LENGTH).asIntBuffer(), be);
|
||||
ckIntBuffer(ByteBuffer.allocateDirect(LENGTH).asIntBuffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,5 @@ public class OrderLong extends Order {
|
||||
buf = LongBuffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ckLongBuffer(buf, nord);
|
||||
|
||||
ckLongBuffer(ByteBuffer.allocate(LENGTH).asLongBuffer(), be);
|
||||
ckLongBuffer(ByteBuffer.allocateDirect(LENGTH).asLongBuffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -52,8 +52,5 @@ public class OrderShort extends Order {
|
||||
buf = ShortBuffer.allocate(LENGTH);
|
||||
ck(buf.order(), nord);
|
||||
ckShortBuffer(buf, nord);
|
||||
|
||||
ckShortBuffer(ByteBuffer.allocate(LENGTH).asShortBuffer(), be);
|
||||
ckShortBuffer(ByteBuffer.allocateDirect(LENGTH).asShortBuffer(), be);
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,6 @@
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
|
||||
@ -197,6 +194,7 @@ public class BestEffortOnLazyConnected {
|
||||
hostname);
|
||||
// Ignore the test if the hostname does not sound like a domain name.
|
||||
if ((hostname == null) || hostname.isEmpty() ||
|
||||
!hostname.contains(".") || hostname.endsWith(".") ||
|
||||
hostname.startsWith("localhost") ||
|
||||
Character.isDigit(hostname.charAt(hostname.length() - 1))) {
|
||||
|
||||
|
@ -235,6 +235,7 @@ public class ImpactOnSNI {
|
||||
hostname);
|
||||
// Ignore the test if the hostname does not sound like a domain name.
|
||||
if ((hostname == null) || hostname.isEmpty() ||
|
||||
!hostname.contains(".") || hostname.endsWith(".") ||
|
||||
hostname.startsWith("localhost") ||
|
||||
Character.isDigit(hostname.charAt(hostname.length() - 1))) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user