Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API and JavaDoc changes for Spatial Datatypes #752

Merged
merged 28 commits into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
73edf05
Added more exceptions for fuzz testing, and added some more javadocs
peterbae Jul 18, 2018
a09c247
fixing merge break
peterbae Jul 18, 2018
3f694ff
removing log files
peterbae Jul 18, 2018
243f294
javadoc changes
peterbae Jul 19, 2018
537959f
gets -> returns
peterbae Jul 19, 2018
862d71d
add test
peterbae Jul 20, 2018
d86b237
split points into two
peterbae Jul 20, 2018
eac074f
move error message around
peterbae Jul 20, 2018
79c7e59
check neg size for all number of sizes
peterbae Jul 20, 2018
81a065f
reflect comments + make internal spatial datatype file protected
peterbae Jul 23, 2018
7ec6fcc
more javadoc changes
peterbae Jul 23, 2018
272a729
switch lat/long
peterbae Jul 23, 2018
54c5297
refactor out duplicate code
peterbae Jul 23, 2018
a3eb552
add null checking + change int to long
peterbae Jul 23, 2018
0de6184
handle m and z value being null case and add test
peterbae Jul 23, 2018
b4fca56
reuse function
peterbae Jul 23, 2018
3135521
move this part to other PR
peterbae Jul 24, 2018
2dfb95b
reflect comment
peterbae Jul 24, 2018
6f4af3d
bit more javadoc
peterbae Jul 24, 2018
8aba9e6
remove StringIndexOutOfBoundsException
peterbae Jul 25, 2018
589c1c0
check wkt length
peterbae Jul 25, 2018
a61a58b
Merge branch 'dev' into Fuzz_And_Javadoc_fix
peterbae Jul 25, 2018
1d7800d
remove catching runtime exception
peterbae Jul 26, 2018
1f3e437
Merge branch 'Fuzz_And_Javadoc_fix' of https://github.com/peterbae/ms…
peterbae Jul 26, 2018
35d99a8
dont need those imports
peterbae Jul 26, 2018
e156263
use try blocks they're the best
peterbae Jul 26, 2018
5ca2a83
refactor throwing illegal WKT position into a method
peterbae Jul 26, 2018
2f886a0
apparently 0 and null are different, so fix that
peterbae Jul 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/Geography.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package com.microsoft.sqlserver.jdbc;

import java.nio.BufferUnderflowException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to import this?

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.MessageFormat;


public class Geography extends SQLServerSpatialDatatype {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs class description

Expand Down Expand Up @@ -49,8 +51,14 @@ private Geography(byte[] wkb) throws SQLServerException {
buffer = ByteBuffer.wrap(wkb);
buffer.order(ByteOrder.LITTLE_ENDIAN);

parseWkb();

try {
parseWkb();
} catch (NegativeArraySizeException | BufferUnderflowException | OutOfMemoryError e) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ParsingError"));
Object[] msgArgs = {JDBCType.VARBINARY};
throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
}

WKTsb = new StringBuffer();
WKTsbNoZM = new StringBuffer();

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Geometry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package com.microsoft.sqlserver.jdbc;

import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.MessageFormat;


public class Geometry extends SQLServerSpatialDatatype {
Expand Down Expand Up @@ -49,7 +51,13 @@ private Geometry(byte[] wkb) throws SQLServerException {
buffer = ByteBuffer.wrap(wkb);
buffer.order(ByteOrder.LITTLE_ENDIAN);

parseWkb();
try {
parseWkb();
} catch (NegativeArraySizeException | BufferUnderflowException | OutOfMemoryError e) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ParsingError"));
Object[] msgArgs = {JDBCType.VARBINARY};
throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
}

WKTsb = new StringBuffer();
WKTsbNoZM = new StringBuffer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,8 @@ public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQL
} catch (SQLException e) {
// throw a BatchUpdateException with the given error message, and return null for the updateCounts.
throw new BatchUpdateException(e.getMessage(), null, 0, null);
} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this change is not related to Spatial types? You probably need to update the comment below too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this change out of this PR as we already have another active PR to track useBulkCopyWithBatchInsert API changes. It will be easier to track changes there.

// If we fail with IllegalArgumentException, fall back to the original batch insert logic.
if (getStatementLogger().isLoggable(java.util.logging.Level.FINE)) {
getStatementLogger().fine("Parsing user's Batch Insert SQL Query failed: " + e.toString());
Expand Down Expand Up @@ -2154,7 +2155,8 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio
} catch (SQLException e) {
// throw a BatchUpdateException with the given error message, and return null for the updateCounts.
throw new BatchUpdateException(e.getMessage(), null, 0, null);
} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
// If we fail with IllegalArgumentException, fall back to the original batch insert logic.
if (getStatementLogger().isLoggable(java.util.logging.Level.FINE)) {
getStatementLogger().fine("Parsing user's Batch Insert SQL Query failed: " + e.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,14 +1662,30 @@ class Figure {
this.pointOffset = pointOffset;
}

/**
* Returns the figuresAttribute value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am changing everything to be consistent. For getters, can you please say "Gets blah blah"?

*
* @return byte figuresAttribute value.
*/
public byte getFiguresAttribute() {
return figuresAttribute;
}

/**
* Returns the pointOffset value.
*
* @return int pointOffset value.
*/
public int getPointOffset() {
return pointOffset;
}

/**
* Sets the figuresAttribute value.
*
* @param fa
* figuresAttribute value.
*/
public void setFiguresAttribute(byte fa) {
figuresAttribute = fa;
}
Expand All @@ -1691,18 +1707,39 @@ class Shape {
this.openGISType = openGISType;
}

/**
* Returns the parentOffset value.
*
* @return int parentOffset value.
*/
public int getParentOffset() {
return parentOffset;
}

/**
* Returns the figureOffset value.
*
* @return int figureOffset value.
*/
public int getFigureOffset() {
return figureOffset;
}

/**
* Returns the openGISType value.
*
* @return byte openGISType value.
*/
public byte getOpenGISType() {
return openGISType;
}

/**
* Sets the figureOffset value.
*
* @param fo
* figureOffset value.
*/
public void setFigureOffset(int fo) {
figureOffset = fo;
}
Expand All @@ -1721,6 +1758,11 @@ class Segment {
this.segmentType = segmentType;
}

/**
* Returns the segmentType value.
*
* @return byte segmentType value.
*/
public byte getSegmentType() {
return segmentType;
}
Expand All @@ -1744,18 +1786,38 @@ class Point {
this.m = m;
}

/**
* Returns the x coordinate value.
*
* @return double x coordinate value.
*/
public double getX() {
return x;
}

/**
* Returns the y coordinate value.
*
* @return double y coordinate value.
*/
public double getY() {
return y;
}

/**
* Returns the z (elevation) value.
*
* @return double z value.
*/
public double getZ() {
return z;
}

/**
* Returns the m (measure) value.
*
* @return double m value.
*/
public double getM() {
return m;
}
Expand Down