File tree Expand file tree Collapse file tree 7 files changed +3332
-7
lines changed
main/java/org/sourcelab/kafka/webview/ui
java/org/sourcelab/kafka/webview/ui/manager
resources/testDeserializer Expand file tree Collapse file tree 7 files changed +3332
-7
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010#### Bug fixes
1111- Topics shown on brokers now include "internal" topics.
1212- Generated consumer client.id shortened.
13+ - [ #111 ] ( https://github.com/SourceLabOrg/kafka-webview/issues/111 ) Add ProtocolBuffer support to Jackson via third party module.
1314
1415#### Internal Dependency Updates
1516- Upgrade from Spring Boot 2.0.5 to 2.0.7
Original file line number Diff line number Diff line change 134134 <optional >true</optional >
135135 </dependency >
136136
137+ <!-- Jackson support for protocol buffers -->
138+ <dependency >
139+ <groupId >com.hubspot.jackson</groupId >
140+ <artifactId >jackson-datatype-protobuf</artifactId >
141+ <version >0.9.10-jackson2.9-proto3</version >
142+ <exclusions >
143+ <!-- exclude out-dated dependency -->
144+ <exclusion >
145+ <groupId >com.fasterxml.jackson.core</groupId >
146+ <artifactId >jackson-annotations</artifactId >
147+ </exclusion >
148+ <exclusion >
149+ <groupId >com.fasterxml.jackson.core</groupId >
150+ <artifactId >jackson-databind</artifactId >
151+ </exclusion >
152+ <exclusion >
153+ <groupId >com.fasterxml.jackson.core</groupId >
154+ <artifactId >jackson-core</artifactId >
155+ </exclusion >
156+ <exclusion >
157+ <groupId >com.google.guava</groupId >
158+ <artifactId >guava</artifactId >
159+ </exclusion >
160+ </exclusions >
161+ </dependency >
162+ <!-- Explicitly include updated guava version for jackson protobuf module -->
163+ <dependency >
164+ <groupId >com.google.guava</groupId >
165+ <artifactId >guava</artifactId >
166+ <version >27.0.1-jre</version >
167+ </dependency >
168+
137169 <!-- For tests -->
138170 <dependency >
139171 <groupId >org.springframework.boot</groupId >
179211 <scope >test</scope >
180212 </dependency >
181213
214+ <!-- Test case for validating protocol buffer support in Jackson -->
215+ <dependency >
216+ <groupId >com.google.protobuf</groupId >
217+ <artifactId >protobuf-java</artifactId >
218+ <version >3.6.1</version >
219+ <scope >test</scope >
220+ </dependency >
221+
182222 <!-- Embedded LDAP server for tests -->
183223 <dependency >
184224 <groupId >org.zapodot</groupId >
Original file line number Diff line number Diff line change 2424
2525package org .sourcelab .kafka .webview .ui .configuration ;
2626
27+ import com .hubspot .jackson .datatype .protobuf .ProtobufModule ;
2728import org .apache .kafka .common .serialization .Deserializer ;
2829import org .sourcelab .kafka .webview .ui .manager .encryption .SecretManager ;
2930import org .sourcelab .kafka .webview .ui .manager .kafka .KafkaAdminFactory ;
3334import org .sourcelab .kafka .webview .ui .manager .plugin .PluginFactory ;
3435import org .sourcelab .kafka .webview .ui .manager .plugin .UploadManager ;
3536import org .sourcelab .kafka .webview .ui .plugin .filter .RecordFilter ;
37+ import org .springframework .boot .autoconfigure .jackson .Jackson2ObjectMapperBuilderCustomizer ;
3638import org .springframework .context .annotation .Bean ;
3739import org .springframework .stereotype .Component ;
3840
@@ -112,6 +114,18 @@ public KafkaOperationsFactory getKafkaOperationsFactory(final AppProperties appP
112114 );
113115 }
114116
117+ /**
118+ * Customize the jackson object map builder.
119+ * @return Jackson2ObjectMapperBuilderCustomizer instance.
120+ */
121+ @ Bean
122+ public Jackson2ObjectMapperBuilderCustomizer addCustomBigDecimalDeserialization () {
123+ return jacksonObjectMapperBuilder -> {
124+ // Register custom protocol buffer serializer as protocol buffers is a common serialization format.
125+ jacksonObjectMapperBuilder .modulesToInstall (new ProtobufModule ());
126+ };
127+ }
128+
115129 /**
116130 * For creating instances of AdminClient.
117131 */
Original file line number Diff line number Diff line change 3232import java .io .IOException ;
3333
3434/**
35- * Uses object's toString() method to serialize .
35+ * Attempts to serialize using Jackson, if that fails, falls back to using toString .
3636 */
3737public class ToStringSerializer extends JsonSerializer <Object > {
3838 @ Override
@@ -52,8 +52,6 @@ public void serialize(
5252 serializer .serialize (value , gen , serializers );
5353 return ;
5454 }
55-
56- // Fall back to using toString()
5755 gen .writeString (value .toString ());
5856 }
5957}
You can’t perform that action at this time.
0 commit comments