Changeset 18826 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2023-09-12T18:04:57+02:00 (14 months ago)
Author:
taylor.smock
Message:

Fix #23165: Cannot assign a changesetId > 0 to a new primitive

There were two problems:

  1. Using Number.intValue instead of Number.longValue
  2. Using >> instead of >>> (bit shift)
Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/protobuf/ProtobufParser.java

    r18695 r18826  
    5252     * @param start    The start position in the byte array
    5353     * @param end      The end position in the byte array (exclusive - [start, end) )
    54      * @return t
    55      * he number from the byte array. Depending upon length of time the number will be stored, narrowing may be helpful.
     54     * @return the number from the byte array. Depending upon length of time the number will be stored, narrowing may be helpful.
    5655     * @since 18695
    5756     */
     
    101100     */
    102101    public static long decodeZigZag(long signed) {
    103         return (signed >> 1) ^ -(signed & 1);
     102        return (signed >>> 1) ^ -(signed & 1);
    104103    }
    105104
  • trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java

    r18702 r18826  
    632632                switch (protobufRecord.getField()) {
    633633                    case 1:
    634                         id = protobufRecord.asUnsignedVarInt().intValue();
     634                        id = protobufRecord.asUnsignedVarInt().longValue();
    635635                        break;
    636636                    case 2:
     
    699699                switch (protobufRecord.getField()) {
    700700                    case 1:
    701                         id = protobufRecord.asUnsignedVarInt().intValue();
     701                        id = protobufRecord.asUnsignedVarInt().longValue();
    702702                        break;
    703703                    case 2:
     
    838838     */
    839839    private static void setOsmPrimitiveData(PrimitiveBlockRecord primitiveBlockRecord, PrimitiveData primitive, Info info) {
    840         if (info.changeset() != null) {
    841             primitive.setChangesetId(Math.toIntExact(info.changeset()));
    842         }
    843840        primitive.setVisible(info.isVisible());
    844841        if (info.timestamp() != null) {
     
    852849        if (info.version() > 0) {
    853850            primitive.setVersion(info.version());
     851        }
     852        if (info.changeset() != null) {
     853            primitive.setChangesetId(Math.toIntExact(info.changeset()));
    854854        }
    855855    }
Note: See TracChangeset for help on using the changeset viewer.