|
28 | 28 |
|
29 | 29 | import org.jruby.Ruby;
|
30 | 30 | import org.jruby.RubyClass;
|
| 31 | +import org.jruby.RubyFixnum; |
31 | 32 | import org.jruby.RubyModule;
|
| 33 | +import org.jruby.RubyNumeric; |
32 | 34 | import org.jruby.RubyObject;
|
33 | 35 | import org.jruby.RubyString;
|
34 | 36 | import org.jruby.RubyTime;
|
@@ -96,15 +98,30 @@ final javax.net.ssl.SSLSession sslSession() {
|
96 | 98 |
|
97 | 99 | @JRubyMethod(name = "==")
|
98 | 100 | public IRubyObject op_eqq(final ThreadContext context, final IRubyObject other) {
|
| 101 | + return context.runtime.newBoolean( equals(other) ); |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + public boolean equals(final Object other) { |
99 | 106 | if ( other instanceof SSLSession ) {
|
100 | 107 | final SSLSession that = (SSLSession) other;
|
101 | 108 | if ( this.sslSession.getProtocol().equals( that.sslSession.getProtocol() ) ) {
|
102 | 109 | if ( Arrays.equals( this.sslSession.getId(), that.sslSession.getId() ) ) {
|
103 |
| - return context.runtime.getTrue(); |
| 110 | + return true; |
104 | 111 | }
|
105 | 112 | }
|
106 | 113 | }
|
107 |
| - return context.runtime.getFalse(); |
| 114 | + return false; |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public final int hashCode() { |
| 119 | + return 17 * sslSession.hashCode(); |
| 120 | + } |
| 121 | + |
| 122 | + @Override |
| 123 | + public RubyFixnum hash() { |
| 124 | + return getRuntime().newFixnum(hashCode()); |
108 | 125 | }
|
109 | 126 |
|
110 | 127 | @JRubyMethod(name = "id")
|
@@ -146,8 +163,7 @@ public IRubyObject set_timeout(final ThreadContext context, IRubyObject timeout)
|
146 | 163 | warn(context, "WARNING: can not set Session#timeout=("+ timeout +") no session context");
|
147 | 164 | return context.nil;
|
148 | 165 | }
|
149 |
| - final long t = timeout.convertToInteger().getLongValue(); |
150 |
| - sessionContext.setSessionTimeout((int) t); // in seconds as well |
| 166 | + sessionContext.setSessionTimeout(RubyNumeric.fix2int(timeout)); // in seconds as well |
151 | 167 | return timeout;
|
152 | 168 | }
|
153 | 169 |
|
|
0 commit comments