@@ -816,10 +816,10 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
816
816
final int length = RubyNumeric .fix2int (len );
817
817
final RubyString buffStr ;
818
818
819
- if ( buff != null && ! buff .isNil () ) {
820
- buffStr = buff .asString ();
819
+ if ( ! buff .isNil () ) {
820
+ buffStr = buff .convertToString ();
821
821
} else {
822
- buffStr = RubyString .newEmptyString (runtime ); // fine since we're setValue
822
+ buffStr = RubyString .newEmptyString (runtime ); // fine since we'll setValue
823
823
}
824
824
if ( length == 0 ) {
825
825
buffStr .clear ();
@@ -848,7 +848,7 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
848
848
849
849
if ( read == -1 ) {
850
850
if ( exception ) throw runtime .newEOFError ();
851
- return runtime . getNil () ;
851
+ return context . nil ;
852
852
}
853
853
854
854
if ( read == 0 && status == SSLEngineResult .Status .BUFFER_UNDERFLOW ) {
@@ -873,7 +873,7 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
873
873
874
874
@ JRubyMethod
875
875
public IRubyObject sysread (ThreadContext context , IRubyObject len ) {
876
- return sysreadImpl (context , len , null , true , true );
876
+ return sysreadImpl (context , len , context . nil , true , true );
877
877
}
878
878
879
879
@ JRubyMethod
@@ -895,14 +895,14 @@ public IRubyObject sysread(ThreadContext context, IRubyObject[] args) {
895
895
896
896
@ JRubyMethod
897
897
public IRubyObject sysread_nonblock (ThreadContext context , IRubyObject len ) {
898
- return sysreadImpl (context , len , null , false , true );
898
+ return sysreadImpl (context , len , context . nil , false , true );
899
899
}
900
900
901
901
@ JRubyMethod
902
902
public IRubyObject sysread_nonblock (ThreadContext context , IRubyObject len , IRubyObject arg ) {
903
903
if ( arg instanceof RubyHash ) { // exception: false
904
904
// NOTE: on Ruby 2.3 this is expected to raise a TypeError (but not on 2.2)
905
- return sysreadImpl (context , len , null , false , getExceptionOpt (context , arg ));
905
+ return sysreadImpl (context , len , context . nil , false , getExceptionOpt (context , arg ));
906
906
}
907
907
return sysreadImpl (context , len , arg , false , true ); // buffer arg
908
908
}
0 commit comments