Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[CONJ-1035] correcting double write of buffer when writing ascii data…
… in case of growing packet buffer
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/java/org/mariadb/jdbc/unit/client/socket/PackerWriterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package org.mariadb.jdbc.unit.client.socket; | ||
|
|
||
| import java.io.IOException; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mariadb.jdbc.client.socket.impl.PacketWriter; | ||
|
|
||
| public class PackerWriterTest { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
|
||
| @Test | ||
| public void growBuffer() throws IOException { | ||
| PacketWriter pw = new PacketWriter(null, 0, 0xffffff, null, null); | ||
| Assertions.assertEquals(4, pw.pos()); | ||
| pw.writeBytes(new byte[8190], 0, 8190); | ||
| pw.writeAscii("abcdefghij"); | ||
| Assertions.assertEquals(8200, pw.pos() - 4); | ||
|
|
||
| for (int i = 0; i < 8190; i++) { | ||
| Assertions.assertEquals(0, pw.buf()[i + 4]); | ||
| } | ||
| for (int i = 0; i < 10; i++) { | ||
| Assertions.assertEquals('a' + i, pw.buf()[i + 8194]); | ||
| } | ||
| } | ||
| } | ||
@rusher might make sense to fix the typo (Packer) in the class name so the test is easier to find :)