equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
54 if (size() < 4) { // 4: handshake message header size |
54 if (size() < 4) { // 4: handshake message header size |
55 // internal_error alert will be triggered |
55 // internal_error alert will be triggered |
56 throw new RuntimeException("handshake message is not available"); |
56 throw new RuntimeException("handshake message is not available"); |
57 } |
57 } |
58 |
58 |
59 // outputRecord cannot be null |
59 if (outputRecord != null) { |
60 outputRecord.encodeHandshake(buf, 0, count); |
60 outputRecord.encodeHandshake(buf, 0, count); |
61 |
61 |
62 // reset the byte array output stream |
62 // reset the byte array output stream |
63 reset(); |
63 reset(); |
|
64 } // otherwise, the handshake outstream is temporarily used only. |
64 } |
65 } |
65 |
66 |
66 // |
67 // |
67 // overridden ByteArrayOutputStream methods |
68 // overridden ByteArrayOutputStream methods |
68 // |
69 // |
74 super.write(b, off, len); |
75 super.write(b, off, len); |
75 } |
76 } |
76 |
77 |
77 @Override |
78 @Override |
78 public void flush() throws IOException { |
79 public void flush() throws IOException { |
79 outputRecord.flush(); |
80 if (outputRecord != null) { |
|
81 outputRecord.flush(); |
|
82 } |
80 } |
83 } |
81 |
84 |
82 // |
85 // |
83 // handshake output stream management functions |
86 // handshake output stream management functions |
84 // |
87 // |
99 super.write(i); |
102 super.write(i); |
100 } |
103 } |
101 |
104 |
102 void putInt24(int i) throws IOException { |
105 void putInt24(int i) throws IOException { |
103 checkOverflow(i, Record.OVERFLOW_OF_INT24); |
106 checkOverflow(i, Record.OVERFLOW_OF_INT24); |
|
107 super.write(i >> 16); |
|
108 super.write(i >> 8); |
|
109 super.write(i); |
|
110 } |
|
111 |
|
112 void putInt32(int i) throws IOException { |
|
113 super.write(i >> 24); |
104 super.write(i >> 16); |
114 super.write(i >> 16); |
105 super.write(i >> 8); |
115 super.write(i >> 8); |
106 super.write(i); |
116 super.write(i); |
107 } |
117 } |
108 |
118 |