21
21
import io .lettuce .core .models .stream .PendingMessage ;
22
22
import io .lettuce .core .models .stream .PendingMessages ;
23
23
24
- import java .nio .ByteBuffer ;
25
24
import java .time .Duration ;
26
- import java .util .ArrayList ;
27
25
import java .util .List ;
28
26
29
27
import org .springframework .core .convert .converter .Converter ;
34
32
import org .springframework .data .redis .connection .stream .RecordId ;
35
33
import org .springframework .data .redis .connection .stream .StreamReadOptions ;
36
34
import org .springframework .data .redis .connection .stream .StreamRecords ;
37
- import org .springframework .data .redis .util .ByteUtils ;
38
- import org .springframework .lang .Nullable ;
39
- import org .springframework .util .NumberUtils ;
40
35
41
36
/**
42
37
* Converters for Redis Stream-specific types.
@@ -76,10 +71,6 @@ static Converter<StreamMessage<byte[], byte[]>, ByteRecord> byteRecordConverter(
76
71
return (it ) -> StreamRecords .newRecord ().in (it .getStream ()).withId (it .getId ()).ofBytes (it .getBody ());
77
72
}
78
73
79
- static Converter <StreamMessage <byte [], byte []>, RecordId > messageToIdConverter () {
80
- return (it ) -> RecordId .of (it .getId ());
81
- }
82
-
83
74
/**
84
75
* Convert the raw Lettuce xpending result to {@link PendingMessages}.
85
76
*
@@ -106,7 +97,7 @@ static org.springframework.data.redis.connection.stream.PendingMessages toPendin
106
97
}
107
98
108
99
/**
109
- * Convert the raw Lettuce xpending result to {@link PendingMessagesSummary}.
100
+ * Convert the raw Lettuce {@code xpending} result to {@link PendingMessagesSummary}.
110
101
*
111
102
* @param groupName
112
103
* @param source the raw lettuce response.
@@ -123,38 +114,6 @@ static PendingMessagesSummary toPendingMessagesInfo(String groupName, PendingMes
123
114
return new PendingMessagesSummary (groupName , source .getCount (), range , source .getConsumerMessageCount ());
124
115
}
125
116
126
- /**
127
- * We need to convert values into the correct target type since lettuce will give us {@link ByteBuffer} or arrays but
128
- * the parser requires us to have them as {@link String} or numeric values. Oh and {@literal null} values aren't real
129
- * good citizens as well, so we make them empty strings instead - see it works - somehow ;P
130
- *
131
- * @param value dont't get me started om this.
132
- * @return preconverted values that Lettuce parsers are able to understand \ö/.
133
- */
134
- private static Object preConvertNativeValues (@ Nullable Object value ) {
135
-
136
- if (value instanceof ByteBuffer || value instanceof byte []) {
137
-
138
- byte [] targetArray = value instanceof ByteBuffer byteBuffer ? ByteUtils .getBytes (byteBuffer ) : (byte []) value ;
139
- String tmp = LettuceConverters .toString (targetArray );
140
-
141
- try {
142
- return NumberUtils .parseNumber (tmp , Long .class );
143
- } catch (NumberFormatException ex ) {
144
- return tmp ;
145
- }
146
- }
147
- if (value instanceof List listValue ) {
148
- List <Object > targetList = new ArrayList <>();
149
- for (Object it : listValue ) {
150
- targetList .add (preConvertNativeValues (it ));
151
- }
152
- return targetList ;
153
- }
154
-
155
- return value != null ? value : "" ;
156
- }
157
-
158
117
/**
159
118
* {@link Converter} to convert {@link StreamReadOptions} to Lettuce's {@link XReadArgs}.
160
119
*/
0 commit comments