Commit e5dc7e0
authored
Resuable
__Problem__
`PayloadImpl` caches `data` and `metadata` buffers. This means once those buffers are read, they can not be reused as the pointer of `ByteBuffer` has moved to the end of buffer.
This restricts the usage of `PayloadImpl` instance with something like:
```java
socket.requestResponse(new PayloadImpl("Hello")).retry(2);
```
For any retry in the above code, data read from the payload instance will be empty.
__Modification__
- store buffer `position()` on creation and reset them on every `get()`.
- Additional constructor to override this behavior and create a payload for single use.
- `PayloadImpl` defaults to reusable payload.
__Result__
Possible to retry a request without having a custom `Payload` implementation.Payload (#209)1 parent f419554 commit e5dc7e0
File tree
2 files changed
+94
-1
lines changed- reactivesocket-core/src
- main/java/io/reactivesocket/util
- test/java/io/reactivesocket/util
2 files changed
+94
-1
lines changedLines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
64 | 87 | | |
| 88 | + | |
65 | 89 | | |
| 90 | + | |
| 91 | + | |
66 | 92 | | |
67 | 93 | | |
68 | 94 | | |
69 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
70 | 99 | | |
71 | 100 | | |
72 | 101 | | |
73 | 102 | | |
74 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
75 | 107 | | |
76 | 108 | | |
77 | 109 | | |
| |||
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
0 commit comments