This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit bdcfd20791535035128427eef0575d0deca640d0
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Oct 6 16:17:33 2024 -0400

    Internal refactoring
---
 .../commons/imaging/bytesource/ByteSource.java     | 30 +++++++++++-----------
 .../imaging/formats/dcx/DcxImageParser.java        |  2 +-
 .../imaging/bytesource/ByteSourceDataTest.java     |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java 
b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
index eba39497..a7dcf612 100644
--- a/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
+++ b/src/main/java/org/apache/commons/imaging/bytesource/ByteSource.java
@@ -43,6 +43,21 @@ public class ByteSource {
         return new ByteSource(new FileOrigin(file), file.getName());
     }
 
+    public static final InputStream getInputStream(final ByteSource 
byteSource, final long skip) throws IOException {
+        InputStream is = null;
+        boolean succeeded = false;
+        try {
+            is = byteSource.getInputStream();
+            BinaryFunctions.skipBytes(is, skip);
+            succeeded = true;
+        } finally {
+            if (!succeeded) {
+                IOUtils.close(is);
+            }
+        }
+        return is;
+    }
+
     public static ByteSource inputStream(final InputStream is, final String 
name) {
         return new InputStreamByteSource(is, name);
     }
@@ -71,21 +86,6 @@ public class ByteSource {
         return origin.getInputStream();
     }
 
-    public final InputStream getInputStream(final long skip) throws 
IOException {
-        InputStream is = null;
-        boolean succeeded = false;
-        try {
-            is = getInputStream();
-            BinaryFunctions.skipBytes(is, skip);
-            succeeded = true;
-        } finally {
-            if (!succeeded) {
-                IOUtils.close(is);
-            }
-        }
-        return is;
-    }
-
     /**
      * This operation can be VERY expensive; for InputStream byte sources, the 
entire stream must be drained to determine its length.
      *
diff --git 
a/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java 
b/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
index ec095e2a..bf3dc318 100644
--- a/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
@@ -91,7 +91,7 @@ public class DcxImageParser extends 
AbstractImageParser<PcxImagingParameters> {
         final List<BufferedImage> images = new ArrayList<>();
         final PcxImageParser pcxImageParser = new PcxImageParser();
         for (final long element : dcxHeader.pageTable) {
-            try (InputStream stream = byteSource.getInputStream(element)) {
+            try (InputStream stream = ByteSource.getInputStream(byteSource, 
element)) {
                 
images.add(pcxImageParser.getBufferedImage(ByteSource.inputStream(stream, 
null), new PcxImagingParameters()));
             }
         }
diff --git 
a/src/test/java/org/apache/commons/imaging/bytesource/ByteSourceDataTest.java 
b/src/test/java/org/apache/commons/imaging/bytesource/ByteSourceDataTest.java
index 9d842de5..13378182 100644
--- 
a/src/test/java/org/apache/commons/imaging/bytesource/ByteSourceDataTest.java
+++ 
b/src/test/java/org/apache/commons/imaging/bytesource/ByteSourceDataTest.java
@@ -145,7 +145,7 @@ public class ByteSourceDataTest extends 
AbstractByteSourceTest {
 
             final int start = src.length / 2;
 
-            try (InputStream is = byteSource.getInputStream(start)) {
+            try (InputStream is = ByteSource.getInputStream(byteSource, 
start)) {
                 final byte[] dst = IOUtils.toByteArray(is);
 
                 assertEquals(src.length, dst.length + start);

Reply via email to