File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 3
3
public class CompoundPipeRunnable extends SimplePipeRunnable {
4
4
5
5
private static String nextSessionKey () {
6
- String hexStr = "0123456789abcdef" ;
7
- String key = "" ;
6
+ StringBuffer keyBuffer = new StringBuffer (4 );
8
7
for (int i = 0 ; i < 4 ; i ++) {
9
- int hex = (int ) Math .round ( 15 * Math .random ());
10
- key += "" + hexStr . charAt ( hex );
8
+ int hex = (int ) Math .floor ( Math .random () * 16 );
9
+ keyBuffer . append (( char ) ( hex < 10 ? ( '0' + hex ) : ( 'a' + hex - 10 )) );
11
10
}
12
- return key ;
11
+ return keyBuffer . toString () ;
13
12
}
14
13
15
14
CompoundPipeSession [] pipes ;
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ synchronized static String registerPipe(SimplePipeRunnable pipe) {
120
120
static String nextPipeKey () {
121
121
StringBuffer buf = new StringBuffer (SimplePipeRequest .PIPE_KEY_LENGTH );
122
122
for (int i = 0 ; i < SimplePipeRequest .PIPE_KEY_LENGTH ; i ++) {
123
- int r = (int ) Math .round (( float ) Math .random () * 61 ); // 0..61, total 62 numbers
123
+ int r = (int ) Math .floor ( Math .random () * 62 ); // 0..61, total 62 numbers
124
124
if (r < 10 ) {
125
125
buf .append ((char ) (r + '0' ));
126
126
} else if (r < 10 + 26 ) {
You can’t perform that action at this time.
0 commit comments