Skip to content

Commit 054efe5

Browse files
committed
Fix whitespace formatting
1 parent 0d51b25 commit 054efe5

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -92,56 +92,56 @@ public void put(final URL url, Object obj, HttpClient http) {
9292
// after cacheLock is released.
9393
HttpClient oldClient = null;
9494
synchronized (this) {
95-
boolean startThread = (keepAliveTimer == null);
96-
if (!startThread) {
97-
if (!keepAliveTimer.isAlive()) {
98-
startThread = true;
95+
boolean startThread = (keepAliveTimer == null);
96+
if (!startThread) {
97+
if (!keepAliveTimer.isAlive()) {
98+
startThread = true;
99+
}
99100
}
100-
}
101-
if (startThread) {
102-
clear();
103-
/* Unfortunately, we can't always believe the keep-alive timeout we got
104-
* back from the server. If I'm connected through a Netscape proxy
105-
* to a server that sent me a keep-alive
106-
* time of 15 sec, the proxy unilaterally terminates my connection
107-
* The robustness to get around this is in HttpClient.parseHTTP()
108-
*/
109-
final KeepAliveCache cache = this;
110-
AccessController.doPrivileged(new PrivilegedAction<Void>() {
111-
public Void run() {
112-
// We want to create the Keep-Alive-Timer in the
113-
// system threadgroup
114-
ThreadGroup grp = Thread.currentThread().getThreadGroup();
115-
ThreadGroup parent = null;
116-
while ((parent = grp.getParent()) != null) {
117-
grp = parent;
118-
}
101+
if (startThread) {
102+
clear();
103+
/* Unfortunately, we can't always believe the keep-alive timeout we got
104+
* back from the server. If I'm connected through a Netscape proxy
105+
* to a server that sent me a keep-alive
106+
* time of 15 sec, the proxy unilaterally terminates my connection
107+
* The robustness to get around this is in HttpClient.parseHTTP()
108+
*/
109+
final KeepAliveCache cache = this;
110+
AccessController.doPrivileged(new PrivilegedAction<Void>() {
111+
public Void run() {
112+
// We want to create the Keep-Alive-Timer in the
113+
// system threadgroup
114+
ThreadGroup grp = Thread.currentThread().getThreadGroup();
115+
ThreadGroup parent = null;
116+
while ((parent = grp.getParent()) != null) {
117+
grp = parent;
118+
}
119119

120-
keepAliveTimer = new Thread(grp, cache, "Keep-Alive-Timer");
121-
keepAliveTimer.setDaemon(true);
122-
keepAliveTimer.setPriority(Thread.MAX_PRIORITY - 2);
123-
// Set the context class loader to null in order to avoid
124-
// keeping a strong reference to an application classloader.
125-
keepAliveTimer.setContextClassLoader(null);
126-
keepAliveTimer.start();
127-
return null;
128-
}
129-
});
130-
}
120+
keepAliveTimer = new Thread(grp, cache, "Keep-Alive-Timer");
121+
keepAliveTimer.setDaemon(true);
122+
keepAliveTimer.setPriority(Thread.MAX_PRIORITY - 2);
123+
// Set the context class loader to null in order to avoid
124+
// keeping a strong reference to an application classloader.
125+
keepAliveTimer.setContextClassLoader(null);
126+
keepAliveTimer.start();
127+
return null;
128+
}
129+
});
130+
}
131131

132-
KeepAliveKey key = new KeepAliveKey(url, obj);
133-
ClientVector v = super.get(key);
132+
KeepAliveKey key = new KeepAliveKey(url, obj);
133+
ClientVector v = super.get(key);
134134

135-
if (v == null) {
136-
int keepAliveTimeout = http.getKeepAliveTimeout();
137-
v = new ClientVector(keepAliveTimeout > 0 ?
138-
keepAliveTimeout * 1000 : LIFETIME);
139-
v.put(http);
140-
super.put(key, v);
141-
} else {
135+
if (v == null) {
136+
int keepAliveTimeout = http.getKeepAliveTimeout();
137+
v = new ClientVector(keepAliveTimeout > 0 ?
138+
keepAliveTimeout * 1000 : LIFETIME);
139+
v.put(http);
140+
super.put(key, v);
141+
} else {
142142
oldClient = v.put(http);
143+
}
143144
}
144-
}
145145
// close after releasing locks
146146
if (oldClient != null) {
147147
oldClient.closeServer();
@@ -267,7 +267,7 @@ synchronized HttpClient get() {
267267
}
268268

269269
long currentTime = System.currentTimeMillis();
270-
if ((currentTime - e.idleStartTime) > nap) {
270+
if ((currentTime - e.idleStartTime) > nap) {
271271
return null; // all connections stale - will be cleaned up later
272272
} else {
273273
pollFirst();
@@ -280,15 +280,15 @@ synchronized HttpClient put(HttpClient h) {
280280
HttpClient staleClient = null;
281281
assert KeepAliveCache.getMaxConnections() > 0;
282282
if (size() >= KeepAliveCache.getMaxConnections()) {
283-
// remove oldest connection
284-
staleClient = removeLast().hc;
283+
// remove oldest connection
284+
staleClient = removeLast().hc;
285285
}
286286
addFirst(new KeepAliveEntry(h, System.currentTimeMillis()));
287287
// close after releasing the locks
288288
return staleClient;
289289
}
290290

291-
/* remove an HttpClient */
291+
/* remove an HttpClient */
292292
synchronized boolean remove(HttpClient h) {
293293
for (KeepAliveEntry curr : this) {
294294
if (curr.hc == h) {

0 commit comments

Comments
 (0)