Skip to content
Merged
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
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@
<version>${slf4jVersion}</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>

<!-- testing support -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/
package org.apache.maven.shared.dependency.analyzer.asm;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;

import org.apache.commons.io.IOUtils;
import org.apache.maven.shared.dependency.analyzer.ClassFileVisitor;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
Expand All @@ -41,6 +41,8 @@
* @see #getDependencies()
*/
public class DependencyClassFileVisitor implements ClassFileVisitor {
private static final int BUF_SIZE = 8192;

private final ResultCollector resultCollector = new ResultCollector();

private final Logger logger = LoggerFactory.getLogger(getClass());
Expand All @@ -54,7 +56,7 @@ public DependencyClassFileVisitor() {}
@Override
public void visitClass(String className, InputStream in) {
try {
byte[] byteCode = IOUtils.toByteArray(in);
byte[] byteCode = toByteArray(in);
ClassReader reader = new ClassReader(byteCode);

final Set<String> constantPoolClassRefs = ConstantPoolParser.getConstantPoolClassReferences(byteCode);
Expand Down Expand Up @@ -82,6 +84,16 @@ public void visitClass(String className, InputStream in) {
}
}

private byte[] toByteArray(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[BUF_SIZE];
int i;
while ((i = in.read(buffer)) > 0) {
out.write(buffer, 0, i);
}
return out.toByteArray();
}

/**
* <p>getDependencies.</p>
*
Expand Down