Skip to content

Commit

Permalink
Updated to pass the build after the rebase.
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>

# Conflicts:
#	appserver/tests/testcontainers/pom.xml
#	appserver/tests/testcontainers/src/test/java/org/glassfish/main/test/tc/DomainRestartITest.java
#	appserver/tests/testcontainers/src/test/java/org/glassfish/main/test/tc/GlassFishContainer.java
  • Loading branch information
dmatej committed Feb 20, 2024
1 parent f6a14a9 commit 73bbe70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private byte[] readByteCode(final String className) throws ClassNotFoundExceptio
throw new ClassNotFoundException(className);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileUtils.copy(is, baos, is.available());
FileUtils.copy(is, baos);
return baos.toByteArray();
} catch (IOException e) {
throw new ClassNotFoundException(className, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.System.Logger;
Expand Down Expand Up @@ -292,9 +291,8 @@ private static void extractResource(JarFile jarFile, File loaderDir, String path
LOG.log(WARNING, UNABLE_TO_CREATE, resourceFile.getParentFile());
}

try (InputStream is = jarFile.getInputStream(jarEntry);
FileOutputStream os = new FileOutputStream(resourceFile)) {
FileUtils.copy(is, os, Long.MAX_VALUE);
try (InputStream is = jarFile.getInputStream(jarEntry)) {
FileUtils.copy(is, resourceFile, jarEntry.getSize());
} catch (IOException e) {
LOG.log(WARNING, "Failed to copy entry " + jarEntry, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,16 +742,22 @@ static boolean isValidString(String s) {


/**
* @param in It will be closed after processing, doesn't need to be buffered as this method uses
* own 8K buffer.
* FIXME: Document and write test with large zip file to see if it wouldn't be better to use
* BufferedInputStream and BufferedOutputStream.
* FIXME: Usually used with JarFile and it's entry. Add API.
* <p>
* WARNING: Don't use it when you don't know the byteCount value.
*
* @param in It will be closed after processing.
* @param out Target output file.
* @param bytes Maximal count of bytes to be transferred
* @param byteCount count of bytes to be transferred.
* @throws IOException
*/
public static void copy(InputStream in, File out, long bytes) throws IOException {
try (ReadableByteChannel inputChannel = Channels.newChannel(in);
public static void copy(InputStream in, File out, long byteCount) throws IOException {
try (
ReadableByteChannel inputChannel = Channels.newChannel(in);
FileOutputStream output = new FileOutputStream(out)) {
output.getChannel().transferFrom(inputChannel, 0, bytes);
output.getChannel().transferFrom(inputChannel, 0, byteCount);
}
}

Expand Down

0 comments on commit 73bbe70

Please sign in to comment.