comparison src/org/eclipse/jetty/io/JBuffer.java @ 1060:957f758dcffc

fix JBuffer.get()
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 08 Nov 2016 05:51:00 -0700
parents 013939bfc9e8
children c880589715c7
comparison
equal deleted inserted replaced
1059:013939bfc9e8 1060:957f758dcffc
96 public int space() { 96 public int space() {
97 return bb.capacity() - bb.limit(); 97 return bb.capacity() - bb.limit();
98 } 98 }
99 99
100 100
101 public int get(byte[] b, int offset, int length) { 101 public void get(byte[] b, int offset, int length) {
102 int remaining = bb.remaining();
103 if( remaining == 0 )
104 return -1;
105 if( length > remaining )
106 length = remaining;
107 bb.get(b,offset,length); 102 bb.get(b,offset,length);
108 return length;
109 } 103 }
110 104
111 105
112 public int put(JBuffer src) { 106 public int put(JBuffer src) {
113 return put(src.asArray()); 107 return put(src.asArray());
168 if( n > 0 ) 162 if( n > 0 )
169 bb.limit(put+n); 163 bb.limit(put+n);
170 return n; 164 return n;
171 } 165 }
172 166
173 public final byte[] asArray() { 167 private final byte[] asArray() {
174 byte[] bytes = new byte[remaining()]; 168 byte[] bytes = new byte[remaining()];
175 bb.duplicate().get(bytes); 169 bb.duplicate().get(bytes);
176 return bytes; 170 return bytes;
177 } 171 }
178 172