Skip to content

Commit ccffb7d

Browse files
authored
removing thread local in geospatial (#1102)
## Description Removing thread local in geospatial wkt converter. Cleaning up thread local objects is currently missing in the codebase. We need to update the implementation to create new instance for every usage of wkb/wkt reader as part of future geospatial features. So insteading of adding more complexity with thread local cleaning, removing this entirely. ## Testing Existing unit tests cover the changes made in this PR ## Additional Notes to the Reviewer <!-- Share any additional context or insights that may help the reviewer understand the changes better. This could include challenges faced, limitations, or compromises made during the development process. Also, mention any areas of the code that you would like the reviewer to focus on specifically. --> NO_CHANGELOG=true Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
1 parent d2b846c commit ccffb7d

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/main/java/com/databricks/jdbc/api/impl/converters/WKTConverter.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ public class WKTConverter {
2323

2424
private static final JdbcLogger LOGGER = JdbcLoggerFactory.getLogger(WKTConverter.class);
2525

26-
private static final ThreadLocal<WKTReader> WKT_READER = ThreadLocal.withInitial(WKTReader::new);
27-
private static final ThreadLocal<WKBReader> WKB_READER = ThreadLocal.withInitial(WKBReader::new);
28-
2926
/**
3027
* Converts WKT (Well-Known Text) to WKB (Well-Known Binary) format.
3128
*
@@ -44,7 +41,8 @@ public static byte[] toWKB(String wkt) throws DatabricksValidationException {
4441
try {
4542
int ogcDimension = ogcDimensionFromWkt(wkt);
4643
EnumSet<Ordinate> ordinates = determineOrdinates(ogcDimension);
47-
Geometry geometry = WKT_READER.get().read(wkt);
44+
WKTReader reader = new WKTReader();
45+
Geometry geometry = reader.read(wkt);
4846
JTSOGCWKBWriter writer = new JTSOGCWKBWriter(ordinates, ByteOrder.LITTLE_ENDIAN);
4947
return writer.write(geometry);
5048
} catch (ParseException e) {
@@ -65,7 +63,8 @@ public static String toWKT(byte[] wkb) throws DatabricksValidationException {
6563
try {
6664
int ogcDimension = ogcDimensionFromWkb(wkb);
6765
EnumSet<Ordinate> ordinates = determineOrdinates(ogcDimension);
68-
Geometry geometry = WKB_READER.get().read(wkb);
66+
WKBReader reader = new WKBReader();
67+
Geometry geometry = reader.read(wkb);
6968
int outputDimension = ordinates.size();
7069
WKTWriter writer = new WKTWriter(outputDimension);
7170
writer.setOutputOrdinates(ordinates);

0 commit comments

Comments
 (0)