8314261: Make fields final in sun.net.www
Reviewed-by: redestad, jpai, dfuchs
This commit is contained in:
parent
3bb8afba69
commit
a8ab3be371
src/java.base/share/classes/sun/net/www
@ -45,10 +45,10 @@ public class MimeTable implements FileNameMap {
|
|||||||
private static final int HASH_MARK = '#';
|
private static final int HASH_MARK = '#';
|
||||||
|
|
||||||
/** Keyed by content type, returns MimeEntries */
|
/** Keyed by content type, returns MimeEntries */
|
||||||
private Hashtable<String, MimeEntry> entries = new Hashtable<>();
|
private final Hashtable<String, MimeEntry> entries = new Hashtable<>();
|
||||||
|
|
||||||
/** Keyed by file extension (with the .), returns MimeEntries */
|
/** Keyed by file extension (with the .), returns MimeEntries */
|
||||||
private Hashtable<String, MimeEntry> extensionMap = new Hashtable<>();
|
private final Hashtable<String, MimeEntry> extensionMap = new Hashtable<>();
|
||||||
|
|
||||||
// Will be reset if in the platform-specific data file
|
// Will be reset if in the platform-specific data file
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
|
@ -261,7 +261,7 @@ public abstract class URLConnection extends java.net.URLConnection {
|
|||||||
url = null;
|
url = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<String,Void> proxiedHosts = new HashMap<>();
|
private static final HashMap<String,Void> proxiedHosts = new HashMap<>();
|
||||||
|
|
||||||
public static synchronized void setProxiedHost(String host) {
|
public static synchronized void setProxiedHost(String host) {
|
||||||
proxiedHosts.put(host.toLowerCase(Locale.ROOT), null);
|
proxiedHosts.put(host.toLowerCase(Locale.ROOT), null);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,13 +50,13 @@ public class ChunkedInputStream extends InputStream implements Hurryable {
|
|||||||
* The <code>HttpClient</code> that should be notified when the chunked stream has
|
* The <code>HttpClient</code> that should be notified when the chunked stream has
|
||||||
* completed.
|
* completed.
|
||||||
*/
|
*/
|
||||||
private HttpClient hc;
|
private final HttpClient hc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>MessageHeader</code> that is populated with any optional trailer
|
* The <code>MessageHeader</code> that is populated with any optional trailer
|
||||||
* that appear after the last chunk.
|
* that appear after the last chunk.
|
||||||
*/
|
*/
|
||||||
private MessageHeader responses;
|
private final MessageHeader responses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size, in bytes, of the chunk that is currently being read.
|
* The size, in bytes, of the chunk that is currently being read.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -46,7 +46,7 @@ public class ChunkedOutputStream extends OutputStream {
|
|||||||
private static final int EMPTY_CHUNK_HEADER_SIZE = getHeaderSize(0);
|
private static final int EMPTY_CHUNK_HEADER_SIZE = getHeaderSize(0);
|
||||||
|
|
||||||
/* internal buffer */
|
/* internal buffer */
|
||||||
private byte buf[];
|
private final byte[] buf;
|
||||||
/* size of data (excluding footers and headers) already stored in buf */
|
/* size of data (excluding footers and headers) already stored in buf */
|
||||||
private int size;
|
private int size;
|
||||||
/* current index in buf (i.e. buf[count] */
|
/* current index in buf (i.e. buf[count] */
|
||||||
@ -59,11 +59,11 @@ public class ChunkedOutputStream extends OutputStream {
|
|||||||
private PrintStream out;
|
private PrintStream out;
|
||||||
|
|
||||||
/* the chunk size we use */
|
/* the chunk size we use */
|
||||||
private int preferredChunkDataSize;
|
private final int preferredChunkDataSize;
|
||||||
private int preferedHeaderSize;
|
private final int preferredHeaderSize;
|
||||||
private int preferredChunkGrossSize;
|
private final int preferredChunkGrossSize;
|
||||||
/* header for a complete Chunk */
|
/* header for a complete Chunk */
|
||||||
private byte[] completeHeader;
|
private final byte[] completeHeader;
|
||||||
|
|
||||||
private final Lock writeLock = new ReentrantLock();
|
private final Lock writeLock = new ReentrantLock();
|
||||||
|
|
||||||
@ -119,8 +119,8 @@ public class ChunkedOutputStream extends OutputStream {
|
|||||||
getHeaderSize(DEFAULT_CHUNK_SIZE) - FOOTER_SIZE;
|
getHeaderSize(DEFAULT_CHUNK_SIZE) - FOOTER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
preferedHeaderSize = getHeaderSize(preferredChunkDataSize);
|
preferredHeaderSize = getHeaderSize(preferredChunkDataSize);
|
||||||
preferredChunkGrossSize = preferedHeaderSize + preferredChunkDataSize
|
preferredChunkGrossSize = preferredHeaderSize + preferredChunkDataSize
|
||||||
+ FOOTER_SIZE;
|
+ FOOTER_SIZE;
|
||||||
completeHeader = getHeader(preferredChunkDataSize);
|
completeHeader = getHeader(preferredChunkDataSize);
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ public class ChunkedOutputStream extends OutputStream {
|
|||||||
/* adjust a header start index in case the header of the last
|
/* adjust a header start index in case the header of the last
|
||||||
* chunk is shorter then preferedHeaderSize */
|
* chunk is shorter then preferedHeaderSize */
|
||||||
|
|
||||||
int adjustedHeaderStartIndex = preferedHeaderSize -
|
int adjustedHeaderStartIndex = preferredHeaderSize -
|
||||||
getHeaderSize(size);
|
getHeaderSize(size);
|
||||||
|
|
||||||
/* write header */
|
/* write header */
|
||||||
@ -277,7 +277,7 @@ public class ChunkedOutputStream extends OutputStream {
|
|||||||
public void reset() {
|
public void reset() {
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
count = preferedHeaderSize;
|
count = preferredHeaderSize;
|
||||||
size = 0;
|
size = 0;
|
||||||
spaceInCurrentChunk = preferredChunkDataSize;
|
spaceInCurrentChunk = preferredChunkDataSize;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -56,7 +56,7 @@ import sun.util.logging.PlatformLogger;
|
|||||||
public class HttpCapture {
|
public class HttpCapture {
|
||||||
// HttpCapture does blocking I/O operations while holding monitors.
|
// HttpCapture does blocking I/O operations while holding monitors.
|
||||||
// This is not a concern because it is rarely used.
|
// This is not a concern because it is rarely used.
|
||||||
private File file;
|
private final File file;
|
||||||
private boolean incoming = true;
|
private boolean incoming = true;
|
||||||
private BufferedWriter out;
|
private BufferedWriter out;
|
||||||
private static boolean initialized;
|
private static boolean initialized;
|
||||||
|
@ -98,13 +98,13 @@ public class HttpClient extends NetworkClient {
|
|||||||
protected int port;
|
protected int port;
|
||||||
|
|
||||||
/* where we cache currently open, persistent connections */
|
/* where we cache currently open, persistent connections */
|
||||||
protected static KeepAliveCache kac = new KeepAliveCache();
|
protected static final KeepAliveCache kac = new KeepAliveCache();
|
||||||
|
|
||||||
private static boolean keepAliveProp = true;
|
private static final boolean keepAliveProp;
|
||||||
|
|
||||||
// retryPostProp is true by default so as to preserve behavior
|
// retryPostProp is true by default so as to preserve behavior
|
||||||
// from previous releases.
|
// from previous releases.
|
||||||
private static boolean retryPostProp = true;
|
private static final boolean retryPostProp;
|
||||||
|
|
||||||
/* Value of the system property jdk.ntlm.cache;
|
/* Value of the system property jdk.ntlm.cache;
|
||||||
if false, then NTLM connections will not be cached.
|
if false, then NTLM connections will not be cached.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,10 +51,10 @@ class KeepAliveStreamCleaner
|
|||||||
implements Runnable
|
implements Runnable
|
||||||
{
|
{
|
||||||
// maximum amount of remaining data that we will try to cleanup
|
// maximum amount of remaining data that we will try to cleanup
|
||||||
protected static int MAX_DATA_REMAINING = 512;
|
protected static final int MAX_DATA_REMAINING;
|
||||||
|
|
||||||
// maximum amount of KeepAliveStreams to be queued
|
// maximum amount of KeepAliveStreams to be queued
|
||||||
protected static int MAX_CAPACITY = 10;
|
protected static final int MAX_CAPACITY;
|
||||||
|
|
||||||
// timeout for both socket and poll on the queue
|
// timeout for both socket and poll on the queue
|
||||||
protected static final int TIMEOUT = 5000;
|
protected static final int TIMEOUT = 5000;
|
||||||
@ -68,7 +68,7 @@ class KeepAliveStreamCleaner
|
|||||||
int maxData = AccessController.doPrivileged(
|
int maxData = AccessController.doPrivileged(
|
||||||
new PrivilegedAction<Integer>() {
|
new PrivilegedAction<Integer>() {
|
||||||
public Integer run() {
|
public Integer run() {
|
||||||
return NetProperties.getInteger(maxDataKey, MAX_DATA_REMAINING);
|
return NetProperties.getInteger(maxDataKey, 512);
|
||||||
}}).intValue() * 1024;
|
}}).intValue() * 1024;
|
||||||
MAX_DATA_REMAINING = maxData;
|
MAX_DATA_REMAINING = maxData;
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class KeepAliveStreamCleaner
|
|||||||
int maxCapacity = AccessController.doPrivileged(
|
int maxCapacity = AccessController.doPrivileged(
|
||||||
new PrivilegedAction<Integer>() {
|
new PrivilegedAction<Integer>() {
|
||||||
public Integer run() {
|
public Integer run() {
|
||||||
return NetProperties.getInteger(maxCapacityKey, MAX_CAPACITY);
|
return NetProperties.getInteger(maxCapacityKey, 10);
|
||||||
}}).intValue();
|
}}).intValue();
|
||||||
MAX_CAPACITY = maxCapacity;
|
MAX_CAPACITY = maxCapacity;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -42,10 +42,10 @@ import java.text.SimpleDateFormat;
|
|||||||
|
|
||||||
public class FileURLConnection extends URLConnection {
|
public class FileURLConnection extends URLConnection {
|
||||||
|
|
||||||
static String CONTENT_LENGTH = "content-length";
|
private static final String CONTENT_LENGTH = "content-length";
|
||||||
static String CONTENT_TYPE = "content-type";
|
private static final String CONTENT_TYPE = "content-type";
|
||||||
static String TEXT_PLAIN = "text/plain";
|
private static final String TEXT_PLAIN = "text/plain";
|
||||||
static String LAST_MODIFIED = "last-modified";
|
private static final String LAST_MODIFIED = "last-modified";
|
||||||
|
|
||||||
String contentType;
|
String contentType;
|
||||||
InputStream is;
|
InputStream is;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,10 +23,6 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* FTP stream opener.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.net.www.protocol.ftp;
|
package sun.net.www.protocol.ftp;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -84,7 +80,7 @@ public class FtpURLConnection extends URLConnection {
|
|||||||
|
|
||||||
// In case we have to use proxies, we use HttpURLConnection
|
// In case we have to use proxies, we use HttpURLConnection
|
||||||
HttpURLConnection http = null;
|
HttpURLConnection http = null;
|
||||||
private Proxy instProxy;
|
private final Proxy instProxy;
|
||||||
|
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
OutputStream os = null;
|
OutputStream os = null;
|
||||||
|
@ -91,14 +91,14 @@ public class AuthenticationHeader {
|
|||||||
// When set true, do not use Negotiate even if the response
|
// When set true, do not use Negotiate even if the response
|
||||||
// headers suggest so.
|
// headers suggest so.
|
||||||
boolean dontUseNegotiate = false;
|
boolean dontUseNegotiate = false;
|
||||||
static String authPref=null;
|
private static final String authPref;
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AuthenticationHeader: prefer " + preferred_r;
|
return "AuthenticationHeader: prefer " + preferred_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
authPref = GetPropertyAction.privilegedGetProperty("http.auth.preference");
|
String pref = GetPropertyAction.privilegedGetProperty("http.auth.preference");
|
||||||
|
|
||||||
// http.auth.preference can be set to SPNEGO or Kerberos.
|
// http.auth.preference can be set to SPNEGO or Kerberos.
|
||||||
// In fact they means "Negotiate with SPNEGO" and "Negotiate with
|
// In fact they means "Negotiate with SPNEGO" and "Negotiate with
|
||||||
@ -106,12 +106,13 @@ public class AuthenticationHeader {
|
|||||||
// Negotiate. Read NegotiateAuthentication.java to see how they
|
// Negotiate. Read NegotiateAuthentication.java to see how they
|
||||||
// were used later.
|
// were used later.
|
||||||
|
|
||||||
if (authPref != null) {
|
if (pref != null) {
|
||||||
authPref = authPref.toLowerCase(Locale.ROOT);
|
pref = pref.toLowerCase(Locale.ROOT);
|
||||||
if(authPref.equals("spnego") || authPref.equals("kerberos")) {
|
if (pref.equals("spnego") || pref.equals("kerberos")) {
|
||||||
authPref = "negotiate";
|
pref = "negotiate";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
authPref = pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
String hdrname; // Name of the header to look for
|
String hdrname; // Name of the header to look for
|
||||||
|
@ -171,11 +171,7 @@ class DigestAuthentication extends AuthenticationInfo {
|
|||||||
|
|
||||||
private static final int cnoncelen = 40; /* number of characters in cnonce */
|
private static final int cnoncelen = 40; /* number of characters in cnonce */
|
||||||
|
|
||||||
private static Random random;
|
private static final Random random = new Random();
|
||||||
|
|
||||||
static {
|
|
||||||
random = new Random();
|
|
||||||
}
|
|
||||||
|
|
||||||
Parameters () {
|
Parameters () {
|
||||||
serverQop = false;
|
serverQop = false;
|
||||||
|
@ -162,15 +162,15 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||||||
|
|
||||||
|
|
||||||
/* Should we enable buffering of error streams? */
|
/* Should we enable buffering of error streams? */
|
||||||
private static boolean enableESBuffer = false;
|
private static final boolean enableESBuffer;
|
||||||
|
|
||||||
/* timeout waiting for read for buffered error stream;
|
/* timeout waiting for read for buffered error stream;
|
||||||
*/
|
*/
|
||||||
private static int timeout4ESBuffer = 0;
|
private static final int timeout4ESBuffer;
|
||||||
|
|
||||||
/* buffer size for buffered error stream;
|
/* buffer size for buffered error stream;
|
||||||
*/
|
*/
|
||||||
private static int bufSize4ES = 0;
|
private static final int bufSize4ES;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restrict setting of request headers through the public api
|
* Restrict setting of request headers through the public api
|
||||||
@ -264,17 +264,19 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||||||
|
|
||||||
enableESBuffer = Boolean.parseBoolean(
|
enableESBuffer = Boolean.parseBoolean(
|
||||||
props.getProperty("sun.net.http.errorstream.enableBuffering"));
|
props.getProperty("sun.net.http.errorstream.enableBuffering"));
|
||||||
timeout4ESBuffer = GetIntegerAction.privilegedGetProperty(
|
int esBufferTimeout = GetIntegerAction.privilegedGetProperty(
|
||||||
"sun.net.http.errorstream.timeout", 300);
|
"sun.net.http.errorstream.timeout", 300);
|
||||||
if (timeout4ESBuffer <= 0) {
|
if (esBufferTimeout <= 0) {
|
||||||
timeout4ESBuffer = 300; // use the default
|
esBufferTimeout = 300; // use the default
|
||||||
}
|
}
|
||||||
|
timeout4ESBuffer = esBufferTimeout;
|
||||||
|
|
||||||
bufSize4ES = GetIntegerAction.privilegedGetProperty(
|
int esBufSize = GetIntegerAction.privilegedGetProperty(
|
||||||
"sun.net.http.errorstream.bufferSize", 4096);
|
"sun.net.http.errorstream.bufferSize", 4096);
|
||||||
if (bufSize4ES <= 0) {
|
if (esBufSize <= 0) {
|
||||||
bufSize4ES = 4096; // use the default
|
esBufSize = 4096; // use the default
|
||||||
}
|
}
|
||||||
|
bufSize4ES = esBufSize;
|
||||||
|
|
||||||
allowRestrictedHeaders = Boolean.parseBoolean(
|
allowRestrictedHeaders = Boolean.parseBoolean(
|
||||||
props.getProperty("sun.net.http.allowRestrictedHeaders"));
|
props.getProperty("sun.net.http.allowRestrictedHeaders"));
|
||||||
@ -349,7 +351,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||||||
|
|
||||||
/* The headers actually set by the user are recorded here also
|
/* The headers actually set by the user are recorded here also
|
||||||
*/
|
*/
|
||||||
private MessageHeader userHeaders;
|
private final MessageHeader userHeaders;
|
||||||
|
|
||||||
/* Headers and request method cannot be changed
|
/* Headers and request method cannot be changed
|
||||||
* once this flag is set in :-
|
* once this flag is set in :-
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -246,7 +246,7 @@ public class URLJarFile extends JarFile {
|
|||||||
|
|
||||||
|
|
||||||
private class URLJarFileEntry extends JarEntry {
|
private class URLJarFileEntry extends JarEntry {
|
||||||
private JarEntry je;
|
private final JarEntry je;
|
||||||
|
|
||||||
URLJarFileEntry(JarEntry je) {
|
URLJarFileEntry(JarEntry je) {
|
||||||
super(je);
|
super(je);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user