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

Reproduce the false positive PR to test the workflow #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/com/amazon/ion/IonCursor.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.amazon.ion;

import java.io.Closeable;
Expand Down
44 changes: 29 additions & 15 deletions src/com/amazon/ion/Timestamp.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public final class Timestamp
{
private static final boolean APPLY_OFFSET_YES = true;
private static final boolean APPLY_OFFSET_NO = false;
private static final boolean CHECK_FRACTION_YES = true;
private static final boolean CHECK_FRACTION_NO = false;

private static final int NO_MONTH = 0;
private static final int NO_DAY = 0;
Expand Down Expand Up @@ -444,7 +446,7 @@ private void set_fields_from_calendar(Calendar cal,
*/
private Timestamp(int zyear)
{
this(Precision.YEAR, zyear, NO_MONTH, NO_DAY, NO_HOURS, NO_MINUTES, NO_SECONDS, NO_FRACTIONAL_SECONDS, UNKNOWN_OFFSET, APPLY_OFFSET_NO);
this(Precision.YEAR, zyear, NO_MONTH, NO_DAY, NO_HOURS, NO_MINUTES, NO_SECONDS, NO_FRACTIONAL_SECONDS, UNKNOWN_OFFSET, APPLY_OFFSET_NO, CHECK_FRACTION_NO);
}

/**
Expand All @@ -454,7 +456,7 @@ private Timestamp(int zyear)
*/
private Timestamp(int zyear, int zmonth)
{
this(Precision.MONTH, zyear, zmonth, NO_DAY, NO_HOURS, NO_MINUTES, NO_SECONDS, NO_FRACTIONAL_SECONDS, UNKNOWN_OFFSET, APPLY_OFFSET_NO);
this(Precision.MONTH, zyear, zmonth, NO_DAY, NO_HOURS, NO_MINUTES, NO_SECONDS, NO_FRACTIONAL_SECONDS, UNKNOWN_OFFSET, APPLY_OFFSET_NO, CHECK_FRACTION_NO);
}

/**
Expand All @@ -467,7 +469,7 @@ private Timestamp(int zyear, int zmonth)
@Deprecated
public Timestamp(int zyear, int zmonth, int zday)
{
this(Precision.DAY, zyear, zmonth, zday, NO_HOURS, NO_MINUTES, NO_SECONDS, NO_FRACTIONAL_SECONDS, UNKNOWN_OFFSET, APPLY_OFFSET_NO);
this(Precision.DAY, zyear, zmonth, zday, NO_HOURS, NO_MINUTES, NO_SECONDS, NO_FRACTIONAL_SECONDS, UNKNOWN_OFFSET, APPLY_OFFSET_NO, CHECK_FRACTION_NO);
}


Expand All @@ -490,7 +492,7 @@ public Timestamp(int year, int month, int day,
int hour, int minute,
Integer offset)
{
this(Precision.MINUTE, year, month, day, hour, minute, NO_SECONDS, NO_FRACTIONAL_SECONDS, offset, APPLY_OFFSET_YES);
this(Precision.MINUTE, year, month, day, hour, minute, NO_SECONDS, NO_FRACTIONAL_SECONDS, offset, APPLY_OFFSET_YES, CHECK_FRACTION_NO);
}

/**
Expand All @@ -512,7 +514,7 @@ public Timestamp(int year, int month, int day,
int hour, int minute, int second,
Integer offset)
{
this(Precision.SECOND, year, month, day, hour, minute, second, NO_FRACTIONAL_SECONDS, offset, APPLY_OFFSET_YES);
this(Precision.SECOND, year, month, day, hour, minute, second, NO_FRACTIONAL_SECONDS, offset, APPLY_OFFSET_YES, CHECK_FRACTION_NO);
}

/**
Expand Down Expand Up @@ -541,7 +543,7 @@ public Timestamp(int year, int month, int day,
int hour, int minute, int second, BigDecimal frac,
Integer offset)
{
this(Precision.SECOND, year, month, day, hour, minute, second, frac, offset, APPLY_OFFSET_YES);
this(Precision.SECOND, year, month, day, hour, minute, second, frac, offset, APPLY_OFFSET_YES, CHECK_FRACTION_YES);
}

/**
Expand All @@ -564,7 +566,7 @@ public Timestamp(int year, int month, int day,
*/
private Timestamp(Precision p, int zyear, int zmonth, int zday,
int zhour, int zminute, int zsecond, BigDecimal frac,
Integer offset, boolean shouldApplyOffset)
Integer offset, boolean shouldApplyOffset, boolean shouldCheckFraction)
{
boolean dayPrecision = false;

Expand All @@ -573,13 +575,22 @@ private Timestamp(Precision p, int zyear, int zmonth, int zday,
throw new IllegalArgumentException("invalid Precision passed to constructor");
case FRACTION:
case SECOND:
if (frac == null || frac.equals(BigDecimal.ZERO))
if (frac == null)
{
_fraction = null;
}
else if (shouldCheckFraction)
{
if (frac.equals(BigDecimal.ZERO)) {
_fraction = null;
} else {
checkFraction(p, frac);
_fraction = frac;
}
}
else
{
_fraction = frac.abs();
_fraction = frac;
}
_second = checkAndCastSecond(zsecond);
case MINUTE:
Expand All @@ -599,7 +610,7 @@ private Timestamp(Precision p, int zyear, int zmonth, int zday,
_day = checkAndCastDay(zday, zyear, zmonth);
}

_precision = checkFraction(p, _fraction);
_precision = p;

if (shouldApplyOffset && offset != null) {
apply_offset(offset);
Expand Down Expand Up @@ -662,7 +673,7 @@ private Timestamp(Precision p, int zyear, int zmonth, int zday,
{
return new Timestamp(p, zyear, zmonth, zday,
zhour, zminute, zsecond, frac,
offset, APPLY_OFFSET_NO);
offset, APPLY_OFFSET_NO, CHECK_FRACTION_YES);
}

/**
Expand Down Expand Up @@ -1111,7 +1122,7 @@ else if (timezone_start == '+' || timezone_start == '-')

Timestamp ts =
new Timestamp(precision, year, month, day,
hour, minute, seconds, fraction, offset, APPLY_OFFSET_YES);
hour, minute, seconds, fraction, offset, APPLY_OFFSET_YES, CHECK_FRACTION_NO);
return ts;
}

Expand Down Expand Up @@ -1198,7 +1209,8 @@ public Timestamp clone()
_second,
_fraction,
_offset,
APPLY_OFFSET_NO);
APPLY_OFFSET_NO,
CHECK_FRACTION_NO);
}

/**
Expand Down Expand Up @@ -1229,7 +1241,8 @@ private Timestamp make_localtime()
_second,
_fraction,
_offset,
APPLY_OFFSET_NO);
APPLY_OFFSET_NO,
CHECK_FRACTION_NO);
// explicitly apply the local offset to the time field values
localtime.apply_offset(-offset);

Expand Down Expand Up @@ -1344,7 +1357,8 @@ public static Timestamp forSecond(int year, int month, int day,
// Storing them separately is silly.
int s = second.intValue();
BigDecimal frac = second.subtract(BigDecimal.valueOf(s));
return new Timestamp(Precision.SECOND, year, month, day, hour, minute, s, frac, offset, APPLY_OFFSET_YES);
return new Timestamp(Precision.SECOND, year, month, day, hour, minute, s, frac, offset, APPLY_OFFSET_YES,
CHECK_FRACTION_YES);
}


Expand Down
3 changes: 3 additions & 0 deletions src/com/amazon/ion/impl/IonReaderContinuableApplication.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.amazon.ion.impl;

import com.amazon.ion.IonType;
Expand Down
3 changes: 3 additions & 0 deletions src/com/amazon/ion/impl/IonReaderContinuableCore.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.amazon.ion.impl;

import com.amazon.ion.Decimal;
Expand Down
Loading