Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IOException from signatures, cannot be thrown #113

Merged
merged 1 commit into from
Nov 16, 2017
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
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()
{
}
}