Skip to content

Commit 52f011e

Browse files
committed
minor syntax changes
1 parent 2f4d168 commit 52f011e

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/main/java/com/opentok/util/HttpClient.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,11 @@ public HttpClient build() {
293293

294294
// credit: https://github.com/AsyncHttpClient/async-http-client/blob/b52a8de5d6a862b5d1652d62f87ce774cbcff156/src/main/java/com/ning/http/client/ProxyServer.java#L99-L127
295295
static ProxyServer createProxyServer(final Proxy proxy) {
296-
if (proxy.type().equals(Proxy.Type.DIRECT)) {
297-
return null;
298-
}
299-
300-
if (!proxy.type().equals(Proxy.Type.HTTP)) {
301-
throw new IllegalArgumentException("Only DIRECT and HTTP Proxies are supported!");
296+
switch (proxy.type()) {
297+
case DIRECT:
298+
return null;
299+
case SOCKS:
300+
throw new IllegalArgumentException("Only DIRECT and HTTP Proxies are supported!");
302301
}
303302

304303
final SocketAddress sa = proxy.address();
@@ -309,18 +308,15 @@ static ProxyServer createProxyServer(final Proxy proxy) {
309308

310309
InetSocketAddress isa = (InetSocketAddress) sa;
311310

312-
if (isa.isUnresolved()) {
313-
return new ProxyServer(isa.getHostName(), isa.getPort());
314-
} else {
315-
return new ProxyServer(isa.getAddress().getHostAddress(), isa.getPort());
316-
}
311+
final String isaHost = isa.isUnresolved() ? isa.getHostName() : isa.getAddress().getHostAddress();
312+
return new ProxyServer(isaHost, isa.getPort());
317313
}
318314
}
319315

320316
static class TokenAuthRequestFilter implements RequestFilter {
321317

322-
private int apiKey;
323-
private String apiSecret;
318+
private final int apiKey;
319+
private final String apiSecret;
324320
private final String authHeader = "X-OPENTOK-AUTH";
325321

326322
public TokenAuthRequestFilter(int apiKey, String apiSecret) {
@@ -332,8 +328,7 @@ public FilterContext filter(FilterContext ctx) throws FilterException {
332328
try {
333329
return new FilterContext.FilterContextBuilder(ctx)
334330
.request(new RequestBuilder(ctx.getRequest())
335-
.addHeader(authHeader,
336-
TokenGenerator.generateToken(apiKey, apiSecret))
331+
.addHeader(authHeader, TokenGenerator.generateToken(apiKey, apiSecret))
337332
.build())
338333
.build();
339334
} catch (OpenTokException e) {

0 commit comments

Comments
 (0)