Merge pull request #41 from overleaf/revert-39-msw-update-deps

Revert "Update dependencies to latest stable versions"
This commit is contained in:
Michael Walker 2018-02-27 11:46:40 +00:00 committed by GitHub
commit 43ae147a05
10 changed files with 115 additions and 80 deletions

View file

@ -12,20 +12,18 @@
</properties>
<build>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-assembly-plugin -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<version>2.5.2</version>
<executions>
<execution>
<phase>package</phase>
@ -48,141 +46,123 @@
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jmock/jmock-junit4 -->
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.8.4</version>
<version>2.8.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlet -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.8.v20171121</version>
<version>9.3.9.v20160517</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.8.v20171121</version>
<version>9.3.9.v20160517</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
<dependency>
<groupId>org.asynchttpclient</groupId>
<groupId>com.ning</groupId>
<artifactId>async-http-client</artifactId>
<version>2.3.0</version>
<version>1.9.38</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit -->
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.10.0.201712302008-r</version>
<version>4.4.1.201607150455-r</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit.http.server -->
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.http.server</artifactId>
<version>4.10.0.201712302008-r</version>
<version>4.4.1.201607150455-r</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0.1</version>
<version>3.8.11.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
<version>2.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client -->
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.23.0</version>
<version>1.22.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.23.0</version>
<version>1.22.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-gson -->
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
<version>1.23.0</version>
<version>1.22.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>1.1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.0-jre</version>
<version>19.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mock-server/mockserver-netty -->
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>5.3.0</version>
<version>3.10.4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.13.0</version>
<scope>test</scope>
<version>1.10.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.274</version>
<version>1.11.28</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
<version>4.5.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.15</version>
<version>1.12</version>
</dependency>
</dependencies>
</project>

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.bridge.resource;
import static org.asynchttpclient.Dsl.*;
import com.ning.http.client.AsyncHttpClient;
import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.data.filestore.RepositoryFile;
@ -31,7 +31,7 @@ public class UrlResourceCache implements ResourceCache {
}
public UrlResourceCache(DBStore dbStore) {
this(dbStore, new NingHttpClient(asyncHttpClient()));
this(dbStore, new NingHttpClient(new AsyncHttpClient()));
}
@Override
@ -82,7 +82,8 @@ public class UrlResourceCache implements ResourceCache {
Log.info("GET -> " + url);
try {
contents = http.get(url, hs -> {
List<String> contentLengths = hs.getAll("Content-Length");
List<String> contentLengths
= hs.getHeaders().get("Content-Length");
if (!maxFileSize.isPresent()) {
return true;
}

View file

@ -1,9 +1,8 @@
package uk.ac.ic.wlgitbridge.bridge.swap.store;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.*;
import java.io.InputStream;
@ -30,7 +29,7 @@ public class S3SwapStore implements SwapStore {
String secret,
String bucketName
) {
s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secret))).build();
s3 = new AmazonS3Client(new BasicAWSCredentials(accessKey, secret));
this.bucketName = bucketName;
}

View file

@ -1,7 +1,6 @@
package uk.ac.ic.wlgitbridge.io.http.ning;
import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.*;
import com.ning.http.client.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.ic.wlgitbridge.util.FunctionT;
@ -24,7 +23,7 @@ public class NingHttpClient implements NingHttpClientFacade {
@Override
public <E extends Exception> byte[] get(
String url,
FunctionT<HttpHeaders, Boolean, E> handler
FunctionT<HttpResponseHeaders, Boolean, E> handler
) throws ExecutionException {
try {
return http
@ -34,19 +33,19 @@ public class NingHttpClient implements NingHttpClientFacade {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@Override
public State onHeadersReceived(
HttpHeaders headers
public STATE onHeadersReceived(
HttpResponseHeaders headers
) throws E {
return handler.apply(headers)
? State.CONTINUE : State.ABORT;
? STATE.CONTINUE : STATE.ABORT;
}
@Override
public State onBodyPartReceived(
public STATE onBodyPartReceived(
HttpResponseBodyPart content
) throws IOException {
bytes.write(content.getBodyPartBytes());
return State.CONTINUE;
return STATE.CONTINUE;
}
@Override

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.io.http.ning;
import io.netty.handler.codec.http.HttpHeaders;
import com.ning.http.client.HttpResponseHeaders;
import uk.ac.ic.wlgitbridge.util.FunctionT;
import java.util.concurrent.ExecutionException;
@ -16,7 +16,7 @@ public interface NingHttpClientFacade {
*/
<E extends Exception> byte[] get(
String url,
FunctionT<HttpHeaders, Boolean, E> handler
FunctionT<HttpResponseHeaders, Boolean, E> handler
) throws ExecutionException;
}

View file

@ -0,0 +1,46 @@
package uk.ac.ic.wlgitbridge.io.http.ning;
import com.ning.http.client.FluentCaseInsensitiveStringsMap;
import com.ning.http.client.HttpResponseHeaders;
import java.util.*;
public class NingHttpHeaders extends HttpResponseHeaders {
private final FluentCaseInsensitiveStringsMap map;
private NingHttpHeaders(FluentCaseInsensitiveStringsMap map) {
this.map = map;
}
public static NingHttpHeadersBuilder builder() {
return new NingHttpHeadersBuilder();
}
@Override
public FluentCaseInsensitiveStringsMap getHeaders() {
return map;
}
public static class NingHttpHeadersBuilder {
private final Map<String, Collection<String>> map;
private NingHttpHeadersBuilder() {
map = new HashMap<>();
}
public NingHttpHeadersBuilder addHeader(String key, String... values) {
map.computeIfAbsent(key, __ -> new ArrayList<>())
.addAll(Arrays.asList(values));
return this;
}
public NingHttpHeaders build() {
return new NingHttpHeaders(
new FluentCaseInsensitiveStringsMap(map));
}
}
}

View file

@ -3,8 +3,7 @@ package uk.ac.ic.wlgitbridge.snapshot.base;
import com.google.api.client.http.*;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.asynchttpclient.AsyncHttpClient;
import static org.asynchttpclient.Dsl.*;
import com.ning.http.client.AsyncHttpClient;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.util.Instance;
import uk.ac.ic.wlgitbridge.util.Log;
@ -18,7 +17,7 @@ import java.util.concurrent.*;
*/
public abstract class Request<T extends Result> {
public static final AsyncHttpClient httpClient = asyncHttpClient();
public static final AsyncHttpClient httpClient = new AsyncHttpClient();
private static final Executor executor = Executors.newCachedThreadPool();

View file

@ -2,7 +2,7 @@ package uk.ac.ic.wlgitbridge.snapshot.servermock.server;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import static org.asynchttpclient.Dsl.*;
import com.ning.http.client.AsyncHttpClient;
import uk.ac.ic.wlgitbridge.util.Log;
import java.io.IOException;
@ -30,9 +30,17 @@ public class PostbackThread extends Thread {
@Override
public void run() {
try {
asyncHttpClient().preparePost(
new AsyncHttpClient().preparePost(
url
).setBody(postback).execute().get().getResponseBody();
} catch (IOException e) {
Log.warn(
"IOException on postback, url: " +
url +
", postback: " +
postback,
e
);
} catch (InterruptedException e) {
Log.warn(
"Interrupted on postback, url: " +

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.application;
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.Response;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import static org.asynchttpclient.Dsl.*;
import org.asynchttpclient.*;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Before;
import org.junit.Rule;
@ -613,22 +613,22 @@ public class WLGitBridgeIntegrationTest {
// With no key, we should get a 404.
String url = "http://127.0.0.1:" + gitBridgePort + "/api/testproj/push.tex";
Response response = asyncHttpClient().prepareGet(url).execute().get();
Response response = new AsyncHttpClient().prepareGet(url).execute().get();
assertEquals(404, response.getStatusCode());
// With an invalid project and no key, we should get a 404.
url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/push.tex";
response = asyncHttpClient().prepareGet(url).execute().get();
response = new AsyncHttpClient().prepareGet(url).execute().get();
assertEquals(404, response.getStatusCode());
// With a bad key for a valid project, we should get a 404.
url = "http://127.0.0.1:" + gitBridgePort + "/api/testproj/push.tex?key=notavalidkey";
response = asyncHttpClient().prepareGet(url).execute().get();
response = new AsyncHttpClient().prepareGet(url).execute().get();
assertEquals(404, response.getStatusCode());
// With a bad key for an invalid project, we should get a 404.
url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/push.tex?key=notavalidkey";
response = asyncHttpClient().prepareGet(url).execute().get();
response = new AsyncHttpClient().prepareGet(url).execute().get();
assertEquals(404, response.getStatusCode());
wlgb.stop();
@ -719,14 +719,14 @@ public class WLGitBridgeIntegrationTest {
// With an invalid project and no key, we should get a 404,
// which is rendered by our custom error handler.
String url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/main.tex";
Response response = asyncHttpClient().prepareGet(url).execute().get();
Response response = new AsyncHttpClient().prepareGet(url).execute().get();
assertEquals(404, response.getStatusCode());
assertEquals("{\"message\":\"HTTP error 404\"}", response.getResponseBody());
// With an unsupported URL outside the api, we should get a 500,
// which is rendered by our custom error handler.
url = "http://127.0.0.1:" + gitBridgePort + "/foo";
response = asyncHttpClient().prepareGet(url).execute().get();
response = new AsyncHttpClient().prepareGet(url).execute().get();
assertEquals(500, response.getStatusCode());
assertEquals("{\"message\":\"HTTP error 500\"}", response.getResponseBody());

View file

@ -1,12 +1,12 @@
package uk.ac.ic.wlgitbridge.bridge.resource;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.DefaultHttpHeaders;
import com.ning.http.client.HttpResponseHeaders;
import org.junit.Test;
import uk.ac.ic.wlgitbridge.bridge.db.noop.NoopDbStore;
import uk.ac.ic.wlgitbridge.bridge.util.CastUtil;
import uk.ac.ic.wlgitbridge.git.exception.SizeLimitExceededException;
import uk.ac.ic.wlgitbridge.io.http.ning.NingHttpClientFacade;
import uk.ac.ic.wlgitbridge.io.http.ning.NingHttpHeaders;
import uk.ac.ic.wlgitbridge.util.FunctionT;
import java.io.IOException;
@ -31,8 +31,11 @@ public class UrlResourceCacheTest {
private final UrlResourceCache cache
= new UrlResourceCache(new NoopDbStore(), http);
private static HttpHeaders withContentLength(long cl) {
return new DefaultHttpHeaders().add("Content-Length", String.valueOf(cl));
private static HttpResponseHeaders withContentLength(long cl) {
return NingHttpHeaders
.builder()
.addHeader("Content-Length", String.valueOf(cl))
.build();
}
private void respondWithContentLength(long cl, long actual)
@ -41,7 +44,7 @@ public class UrlResourceCacheTest {
Object[] args = invoc.getArguments();
//noinspection unchecked
((FunctionT<
HttpHeaders, Boolean, SizeLimitExceededException
HttpResponseHeaders, Boolean, SizeLimitExceededException
>) args[1]).apply(withContentLength(cl));
return new byte[CastUtil.assumeInt(actual)];
});