Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.cdap.common.cli;

import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
Expand All @@ -26,6 +25,7 @@

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.Callable;

/**
Expand Down Expand Up @@ -270,7 +270,7 @@ private void testCommand(Command command, Arguments args, String expectedOutput)
PrintStream printStream = new PrintStream(outputStream);
command.execute(args, printStream);

String output = new String(outputStream.toByteArray(), Charsets.UTF_8);
String output = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
Assert.assertEquals(expectedOutput, output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package io.cdap.common.cli.command;

import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import io.cdap.common.cli.Arguments;
import io.cdap.common.cli.Command;
Expand All @@ -28,6 +27,7 @@

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;

/**
* Tests for {@link HelpCommand}
Expand Down Expand Up @@ -155,7 +155,7 @@ private void testCommandOutput(Command command, Arguments args, String expectedO
PrintStream printStream = new PrintStream(outputStream);
command.execute(args, printStream);

String output = new String(outputStream.toByteArray(), Charsets.UTF_8);
String output = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
Assert.assertEquals(expectedOutput, output);
}
}
4 changes: 2 additions & 2 deletions common-core/src/main/java/io/cdap/common/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package io.cdap.common;

import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableSortedMap;

import java.io.DataOutput;
import java.nio.charset.StandardCharsets;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
Expand Down Expand Up @@ -208,7 +208,7 @@ public static String toString(ByteBuffer buf) {
return null;
}
buf.mark();
String s = Charsets.UTF_8.decode(buf).toString();
String s = StandardCharsets.UTF_8.decode(buf).toString();
buf.reset();
return s;
}
Expand Down
10 changes: 6 additions & 4 deletions common-core/src/main/java/io/cdap/common/ImmutablePair.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package io.cdap.common;

import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;

import java.util.Objects;

/**
* An {@link ImmutablePair} consists of two elements within. The elements once set
Expand Down Expand Up @@ -79,7 +81,7 @@ public B getSecond() {
*/
@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("first", first)
.add("second", second)
.toString();
Expand All @@ -91,7 +93,7 @@ public String toString() {
*/
@Override
public int hashCode() {
return Objects.hashCode(first, second);
return Objects.hash(first, second);
}

/**
Expand All @@ -108,6 +110,6 @@ public boolean equals(Object o) {
return false;
}
ImmutablePair<?, ?> other = (ImmutablePair<?, ?>) o;
return Objects.equal(first, other.first) && Objects.equal(second, other.second);
return Objects.equals(first, other.first) && Objects.equals(second, other.second);
}
}
5 changes: 2 additions & 3 deletions common-core/src/main/java/io/cdap/common/Networks.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

package io.cdap.common;

import com.google.common.base.Charsets;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.ServerSocket;
Expand Down Expand Up @@ -93,6 +92,6 @@ public static String normalizeWebappDiscoveryName(String name) throws Unsupporte
name = name.replace(':', '_');
name = name.replace('/', '_');

return URLEncoder.encode(name, Charsets.UTF_8.name());
return URLEncoder.encode(name, StandardCharsets.UTF_8.name());
}
}
14 changes: 2 additions & 12 deletions common-http/src/main/java/io/cdap/common/http/HttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package io.cdap.common.http;

import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.io.InputSupplier;
import io.cdap.common.ContentProvider;
import io.cdap.common.io.ByteBufferInputStream;

Expand All @@ -32,6 +30,7 @@
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -166,15 +165,6 @@ public Builder addHeaders(@Nullable Map<String, String> headers) {
return this;
}

public Builder withBody(InputSupplier<? extends InputStream> body) {
return withBody(new ContentProvider<InputStream>() {
@Override
public InputStream getInput() throws IOException {
return body.getInput();
}
});
}

public Builder withBody(ContentProvider<? extends InputStream> body) {
this.body = body;
this.bodyLength = null;
Expand All @@ -194,7 +184,7 @@ public InputStream getInput() throws IOException {
}

public Builder withBody(String body) {
return withBody(body, Charsets.UTF_8);
return withBody(body, StandardCharsets.UTF_8);
}

public Builder withBody(String body, Charset charset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.cdap.common.http;

import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.io.ByteStreams;
Expand All @@ -30,6 +28,7 @@
import java.net.HttpURLConnection;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.charset.StandardCharsets;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
import java.util.List;
Expand Down Expand Up @@ -123,7 +122,7 @@ public byte[] getUncompressedResponseBody() {
}

public String getResponseBodyAsString() {
return getResponseBodyAsString(Charsets.UTF_8);
return getResponseBodyAsString(StandardCharsets.UTF_8);
}

public String getResponseBodyAsString(Charset charset) {
Expand Down Expand Up @@ -176,7 +175,7 @@ private byte[] getResponseBodyFromStream() {
}
return ByteStreams.toByteArray(inputStream);
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
} finally {
closeQuietly(inputStream);
inputStream = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package io.cdap.common.http;

import com.google.common.base.Charsets;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;

import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;

/**
* Convenient wrapper of {@link HttpResponse} that makes client code cleaner when dealing with java object that can be
Expand All @@ -35,7 +35,7 @@ public final class ObjectResponse<T> extends HttpResponse {
@SuppressWarnings("unchecked")
public static <T> ObjectResponse<T> fromJsonBody(HttpResponse response, Type typeOfObject, Gson gson) {
T object = response.getResponseBody() == null ?
null : (T) gson.fromJson(new String(response.getResponseBody(), Charsets.UTF_8), typeOfObject);
null : (T) gson.fromJson(new String(response.getResponseBody(), StandardCharsets.UTF_8), typeOfObject);
return new ObjectResponse<T>(response, object);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class HttpRequestsStreamTest extends HttpRequestsTestBase {
@Before
public void setUp() throws Exception {
httpService = new TestHttpService(false);
httpService.startAndWait();
httpService.startAsync().awaitRunning();
}

@After
public void tearDown() {
httpService.stopAndWait();
httpService.stopAsync().awaitTerminated();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class HttpRequestsTest extends HttpRequestsTestBase {
@Before
public void setUp() throws Exception {
httpService = new TestHttpService(false);
httpService.startAndWait();
httpService.startAsync().awaitRunning();
}

@After
public void tearDown() {
httpService.stopAndWait();
httpService.stopAsync().awaitTerminated();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.cdap.common.http;

import com.google.common.base.Charsets;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
Expand Down Expand Up @@ -86,8 +85,8 @@ public void testHttpStatus() throws Exception {

// Expected headers for a request
Multimap<String, String> expectedHeaders = ArrayListMultimap.create();
expectedHeaders.put("headerKey", "headerValue2");
expectedHeaders.put("headerKey", "headerValue1");
expectedHeaders.put("headerKey", "headerValue2");
expectedHeaders.put(HttpHeaderNames.CONTENT_LENGTH.toString(), "0");
testGet("/api/testOkWithHeaders", only(200), only("OK"), only(""), only(expectedHeaders));

Expand Down Expand Up @@ -409,30 +408,30 @@ public void testConflictWithMessagePost(io.netty.handler.codec.http.HttpRequest
public void testPost(FullHttpRequest request,
HttpResponder responder) {
responder.sendString(HttpResponseStatus.OK,
request.content().toString(Charsets.UTF_8) + request.headers().get("sdf"));
request.content().toString(StandardCharsets.UTF_8) + request.headers().get("sdf"));
}

@POST
@Path("/testPost409")
public void testPost409(FullHttpRequest request,
HttpResponder responder) {
responder.sendString(HttpResponseStatus.CONFLICT, request.content().toString(Charsets.UTF_8)
responder.sendString(HttpResponseStatus.CONFLICT, request.content().toString(StandardCharsets.UTF_8)
+ request.headers().get("sdf") + "409");
}

@PUT
@Path("/testPut")
public void testPut(FullHttpRequest request,
HttpResponder responder) {
responder.sendString(HttpResponseStatus.OK, request.content().toString(Charsets.UTF_8)
responder.sendString(HttpResponseStatus.OK, request.content().toString(StandardCharsets.UTF_8)
+ request.headers().get("sdf"));
}

@PUT
@Path("/testPut409")
public void testPut409(FullHttpRequest request,
HttpResponder responder) {
responder.sendString(HttpResponseStatus.CONFLICT, request.content().toString(Charsets.UTF_8)
responder.sendString(HttpResponseStatus.CONFLICT, request.content().toString(StandardCharsets.UTF_8)
+ request.headers().get("sdf") + "409");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class HttpsRequestsTest extends HttpRequestsTestBase {
@Before
public void setUp() throws Exception {
httpsService = new TestHttpService(true);
httpsService.startAndWait();
httpsService.startAsync().awaitRunning();
}

@After
public void tearDown() {
httpsService.stopAndWait();
httpsService.stopAsync().awaitTerminated();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.cdap.common.http;

import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.util.concurrent.AbstractIdleService;
import io.cdap.http.ChannelPipelineModifier;
import io.cdap.http.NettyHttpService;
Expand Down Expand Up @@ -90,7 +90,7 @@ public int getNumConnectionsOpened() {

@Override
public String toString() {
return Objects.toStringHelper(this)
return MoreObjects.toStringHelper(this)
.add("bindAddress", httpService.getBindAddress())
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package io.cdap.common.internal.io;

import com.google.common.base.Objects;
import com.google.common.base.Throwables;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
Expand All @@ -27,6 +25,7 @@
import io.cdap.common.internal.asm.ClassDefinition;

import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;

/**
Expand Down Expand Up @@ -61,7 +60,7 @@ public <T> DatumWriter<T> create(TypeToken<T> type, Schema schema) {
return (DatumWriter<T>) writerClass.getConstructor(Schema.class, FieldAccessorFactory.class)
.newInstance(schema, fieldAccessorFactory);
} catch (Exception e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -121,7 +120,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hashCode(schema, type);
return Objects.hash(schema, type);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.cdap.common.internal.io;

import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand Down Expand Up @@ -795,7 +794,7 @@ private void encodeRecord(GeneratorAdapter mg, Schema schema, TypeToken<?> outpu
mg.invokeVirtual(classType, getEncodeMethod(fieldType, field.getSchema()));
}
} catch (Exception e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Loading