Skip to content

Commit

Permalink
Merge pull request #113 from pjulien/no_io_exception
Browse files Browse the repository at this point in the history
Remove IOException from signatures, cannot be thrown
  • Loading branch information
mjpt777 authored Nov 16, 2017
2 parents 82efa96 + 1a884e4 commit e5b49bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
13 changes: 8 additions & 5 deletions agrona/src/main/java/org/agrona/io/DirectBufferInputStream.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.agrona.DirectBuffer;

import java.io.IOException;
import java.io.InputStream;

/**
Expand Down Expand Up @@ -97,20 +96,20 @@ public boolean markSupported()
return false;
}

public int available() throws IOException
public int available()
{
return length - position;
}

public long skip(final long n) throws IOException
public long skip(final long n)
{
final int skipped = (int)Math.min(n, available());
position += skipped;

return skipped;
}

public int read() throws IOException
public int read()
{
int b = -1;
if (position < length)
Expand All @@ -122,7 +121,7 @@ public int read() throws IOException
return b;
}

public int read(final byte[] dstBytes, final int dstOffset, final int length) throws IOException
public int read(final byte[] dstBytes, final int dstOffset, final int length)
{
int bytesRead = -1;

Expand All @@ -135,4 +134,8 @@ public int read(final byte[] dstBytes, final int dstOffset, final int length) th

return bytesRead;
}

public void close()
{
}
}
9 changes: 6 additions & 3 deletions agrona/src/main/java/org/agrona/io/DirectBufferOutputStream.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.agrona.MutableDirectBuffer;

import java.io.IOException;
import java.io.OutputStream;

/**
Expand Down Expand Up @@ -108,7 +107,7 @@ public int length()
* @param b to be written.
* @throws IllegalStateException if insufficient capacity remains in the buffer.
*/
public void write(final int b) throws IOException
public void write(final int b)
{
if (position == length)
{
Expand All @@ -127,7 +126,7 @@ public void write(final int b) throws IOException
* @param length of the srcBytes to read.
* @throws IllegalStateException if insufficient capacity remains in the buffer.
*/
public void write(final byte[] srcBytes, final int srcOffset, final int length) throws IOException
public void write(final byte[] srcBytes, final int srcOffset, final int length)
{
final long resultingOffset = position + ((long)length);
if (resultingOffset >= this.length)
Expand All @@ -138,4 +137,8 @@ public void write(final byte[] srcBytes, final int srcOffset, final int length)
buffer.putBytes(offset + position, srcBytes, srcOffset, length);
position += length;
}

public void close()
{
}
}
9 changes: 6 additions & 3 deletions agrona/src/main/java/org/agrona/io/ExpandableDirectBufferOutputStream.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.agrona.MutableDirectBuffer;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;

Expand Down Expand Up @@ -108,7 +107,7 @@ public MutableDirectBuffer buffer()
*
* @param b to be written.
*/
public void write(final int b) throws IOException
public void write(final int b)
{
buffer.putByte(offset + position, (byte)b);
++position;
Expand All @@ -121,9 +120,13 @@ public void write(final int b) throws IOException
* @param srcOffset at which to begin reading bytes from the srcBytes.
* @param length of the srcBytes to read.
*/
public void write(final byte[] srcBytes, final int srcOffset, final int length) throws IOException
public void write(final byte[] srcBytes, final int srcOffset, final int length)
{
buffer.putBytes(offset + position, srcBytes, srcOffset, length);
position += length;
}

public void close()
{
}
}

0 comments on commit e5b49bb

Please sign in to comment.