本文整理了Java中org.jruby.Ruby.newErrnoECONNRESETError
方法的一些代码示例,展示了Ruby.newErrnoECONNRESETError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newErrnoECONNRESETError
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newErrnoECONNRESETError
暂无
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public RaiseException newIOErrorFromException(IOException ioe) {
if (ioe instanceof ClosedChannelException) {
throw newErrnoEBADFError();
}
// TODO: this is kinda gross
if(ioe.getMessage() != null) {
if (ioe.getMessage().equals("Broken pipe")) {
throw newErrnoEPIPEError();
} else if (ioe.getMessage().equals("Connection reset by peer") ||
(Platform.IS_WINDOWS && ioe.getMessage().contains("connection was aborted"))) {
throw newErrnoECONNRESETError();
}
return newRaiseException(getIOError(), ioe.getMessage());
} else {
return newRaiseException(getIOError(), "IO Error");
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public RaiseException newIOErrorFromException(IOException ioe) {
if (ioe instanceof ClosedChannelException) {
throw newErrnoEBADFError();
}
// TODO: this is kinda gross
if(ioe.getMessage() != null) {
if (ioe.getMessage().equals("Broken pipe")) {
throw newErrnoEPIPEError();
} else if (ioe.getMessage().equals("Connection reset by peer") ||
(Platform.IS_WINDOWS && ioe.getMessage().contains("connection was aborted"))) {
throw newErrnoECONNRESETError();
}
return newRaiseException(getIOError(), ioe.getMessage());
} else {
return newRaiseException(getIOError(), "IO Error");
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Java does not give us enough information for specific error conditions
* so we are reduced to divining them through string matches...
*/
// TODO: Should ECONNABORTED get thrown earlier in the descriptor itself or is it ok to handle this late?
// TODO: Should we include this into Errno code somewhere do we can use this from other places as well?
private void synthesizeSystemCallError(IOException e) {
String errorMessage = e.getMessage();
// All errors to sysread should be SystemCallErrors, but on a closed stream
// Ruby returns an IOError. Java throws same exception for all errors so
// we resort to this hack...
if ("File not open".equals(errorMessage)) {
throw getRuntime().newIOError(e.getMessage());
} else if ("An established connection was aborted by the software in your host machine".equals(errorMessage)) {
throw getRuntime().newErrnoECONNABORTEDError();
} else if ("Connection reset by peer".equals(e.getMessage())
|| "An existing connection was forcibly closed by the remote host".equals(e.getMessage())) {
throw getRuntime().newErrnoECONNRESETError();
}
throw getRuntime().newSystemCallError(e.getMessage());
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Java does not give us enough information for specific error conditions
* so we are reduced to divining them through string matches...
*/
// TODO: Should ECONNABORTED get thrown earlier in the descriptor itself or is it ok to handle this late?
// TODO: Should we include this into Errno code somewhere do we can use this from other places as well?
private void synthesizeSystemCallError(IOException e) {
String errorMessage = e.getMessage();
// All errors to sysread should be SystemCallErrors, but on a closed stream
// Ruby returns an IOError. Java throws same exception for all errors so
// we resort to this hack...
if ("File not open".equals(errorMessage)) {
throw getRuntime().newIOError(e.getMessage());
} else if ("An established connection was aborted by the software in your host machine".equals(errorMessage)) {
throw getRuntime().newErrnoECONNABORTEDError();
} else if ("Connection reset by peer".equals(e.getMessage())
|| "An existing connection was forcibly closed by the remote host".equals(e.getMessage())) {
throw getRuntime().newErrnoECONNRESETError();
}
throw getRuntime().newSystemCallError(e.getMessage());
}
代码示例来源:origin: org.jruby/jruby-complete
protected static IRubyObject doReceive(RubyBasicSocket socket, final Ruby runtime, final boolean non_block,
int length, ReceiveTuple tuple) throws IOException {
DatagramChannel channel = (DatagramChannel) socket.getChannel();
ByteBuffer buf = ByteBuffer.allocate(length);
InetSocketAddress sender = (InetSocketAddress) channel.receive(buf);
if (sender == null) {
if ( non_block ) { // non-blocking receive
return null; // :wait_readable or "recvfrom(2) would block"
}
else { // see JRUBY-4678
throw runtime.newErrnoECONNRESETError();
}
}
RubyString result = runtime.newString(new ByteList(buf.array(), 0, buf.position(), false));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.jruby/jruby-core
protected static IRubyObject doReceive(RubyBasicSocket socket, final Ruby runtime, final boolean non_block,
int length, ReceiveTuple tuple) throws IOException {
DatagramChannel channel = (DatagramChannel) socket.getChannel();
ByteBuffer buf = ByteBuffer.allocate(length);
InetSocketAddress sender = (InetSocketAddress) channel.receive(buf);
if (sender == null) {
if ( non_block ) { // non-blocking receive
return null; // :wait_readable or "recvfrom(2) would block"
}
else { // see JRUBY-4678
throw runtime.newErrnoECONNRESETError();
}
}
RubyString result = runtime.newString(new ByteList(buf.array(), 0, buf.position(), false));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.jruby/jruby-complete
private static IRubyObject doReceiveMulticast(RubyBasicSocket socket, final Ruby runtime, final boolean non_block,
int length, ReceiveTuple tuple) throws IOException {
ByteBuffer recv = ByteBuffer.wrap(new byte[length]);
SocketAddress address;
DatagramChannel channel = socket.multicastStateManager.getMulticastSocket().getChannel();
address = channel.receive(recv);
if (address == null) {
if ( non_block ) return null; // :wait_readable or raise WaitReadable
throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking");
}
InetSocketAddress sender = (InetSocketAddress) address;
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
recv.flip();
RubyString result = runtime.newString(new ByteList(recv.array(), recv.position(), recv.limit(), false));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.jruby/jruby-core
private static IRubyObject doReceiveMulticast(RubyBasicSocket socket, final Ruby runtime, final boolean non_block,
int length, ReceiveTuple tuple) throws IOException {
ByteBuffer recv = ByteBuffer.wrap(new byte[length]);
SocketAddress address;
DatagramChannel channel = socket.multicastStateManager.getMulticastSocket().getChannel();
address = channel.receive(recv);
if (address == null) {
if ( non_block ) return null; // :wait_readable or raise WaitReadable
throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking");
}
InetSocketAddress sender = (InetSocketAddress) address;
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
recv.flip();
RubyString result = runtime.newString(new ByteList(recv.array(), recv.position(), recv.limit(), false));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceive(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
DatagramChannel channel = (DatagramChannel)getChannel();
ByteBuffer buf = ByteBuffer.allocate(length);
InetSocketAddress sender = (InetSocketAddress)channel.receive(buf);
if (sender == null) {
// noblocking receive
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("recvfrom(2) would block");
} else {
throw runtime.newErrnoEAGAINError("recvfrom(2) would block");
}
}
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(buf.array(), 0, buf.position()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceive(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
DatagramChannel channel = (DatagramChannel)getChannel();
ByteBuffer buf = ByteBuffer.allocate(length);
InetSocketAddress sender = (InetSocketAddress)channel.receive(buf);
if (sender == null) {
// noblocking receive
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("recvfrom(2) would block");
} else {
throw runtime.newErrnoEAGAINError("recvfrom(2) would block");
}
}
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(buf.array(), 0, buf.position()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceiveMulticast(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
byte[] buf2 = new byte[length];
DatagramPacket recv = new DatagramPacket(buf2, buf2.length);
MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
try {
ms.receive(recv);
} catch (IllegalBlockingModeException ibme) {
// MulticastSocket does not support nonblocking
// TODO: Use Java 7 NIO.2 DatagramChannel to do multicast
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking");
} else {
throw runtime.newErrnoEAGAINError("multicast UDP does not support nonblocking");
}
}
InetSocketAddress sender = (InetSocketAddress) recv.getSocketAddress();
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(recv.getData(), 0, recv.getLength()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceiveMulticast(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
byte[] buf2 = new byte[length];
DatagramPacket recv = new DatagramPacket(buf2, buf2.length);
MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
try {
ms.receive(recv);
} catch (IllegalBlockingModeException ibme) {
// MulticastSocket does not support nonblocking
// TODO: Use Java 7 NIO.2 DatagramChannel to do multicast
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking");
} else {
throw runtime.newErrnoEAGAINError("multicast UDP does not support nonblocking");
}
}
InetSocketAddress sender = (InetSocketAddress) recv.getSocketAddress();
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(recv.getData(), 0, recv.getLength()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!