diff options
4 files changed, 22 insertions, 27 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java index d8541aa13d..42db0fecde 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java @@ -266,7 +266,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { throws IOException, ServletException { final HttpServletResponse r = (HttpServletResponse) response; r.setContentType("text/plain"); - r.setCharacterEncoding("UTF-8"); + r.setCharacterEncoding(Constants.CHARACTER_ENCODING); try (PrintWriter w = r.getWriter()) { w.print("OK"); } diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java index 06e7a1dbe6..40a223d92f 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java @@ -47,6 +47,7 @@ import java.net.MalformedURLException; import java.util.List; import java.util.Map; +import org.eclipse.jgit.lib.Constants; import org.junit.Before; import org.junit.Test; @@ -203,7 +204,7 @@ public class ProxyConfigTest { while ((length = inputStream.read(buffer)) != -1) { result.write(buffer, 0, length); } - return result.toString("UTF-8"); + return result.toString(Constants.CHARACTER_ENCODING); } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index 84bb340d24..d7f975b003 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -45,6 +45,8 @@ package org.eclipse.jgit.dircache; +import static java.nio.charset.StandardCharsets.ISO_8859_1; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.EOFException; @@ -53,7 +55,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.text.MessageFormat; @@ -580,9 +581,8 @@ public class DirCache { } } - private static String formatExtensionName(final byte[] hdr) - throws UnsupportedEncodingException { - return "'" + new String(hdr, 0, 4, "ISO-8859-1") + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + private static String formatExtensionName(final byte[] hdr) { + return "'" + new String(hdr, 0, 4, ISO_8859_1) + "'"; //$NON-NLS-1$ //$NON-NLS-2$ } private static boolean is_DIRC(final byte[] hdr) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java index fa2c5291c6..b6e9d319aa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/LargePackedWholeObject.java @@ -104,32 +104,26 @@ final class LargePackedWholeObject extends ObjectLoader { /** {@inheritDoc} */ @Override public ObjectStream openStream() throws MissingObjectException, IOException { - DfsReader ctx = db.newReader(); InputStream in; - try { - in = new PackInputStream(pack, objectOffset + headerLength, ctx); - } catch (IOException packGone) { - // If the pack file cannot be pinned into the cursor, it - // probably was repacked recently. Go find the object - // again and open the stream from that location instead. - // + try (DfsReader ctx = db.newReader()) { try { + in = new PackInputStream(pack, objectOffset + headerLength, ctx); + } catch (IOException packGone) { + // If the pack file cannot be pinned into the cursor, it + // probably was repacked recently. Go find the object + // again and open the stream from that location instead. + // ObjectId obj = pack.getReverseIdx(ctx).findObject(objectOffset); return ctx.open(obj, type).openStream(); - } finally { - ctx.close(); } - } finally { - ctx.close(); - } - // Align buffer to inflater size, at a larger than default block. - // This reduces the number of context switches from the - // caller down into the pack stream inflation. - int bufsz = 8192; - in = new BufferedInputStream( - new InflaterInputStream(in, ctx.inflater(), bufsz), - bufsz); - return new ObjectStream.Filter(type, size, in); + // Align buffer to inflater size, at a larger than default block. + // This reduces the number of context switches from the + // caller down into the pack stream inflation. + int bufsz = 8192; + in = new BufferedInputStream( + new InflaterInputStream(in, ctx.inflater(), bufsz), bufsz); + return new ObjectStream.Filter(type, size, in); + } } } |