From 04eab85bf1535c2edac5744429ca8299205ef81f Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Mon, 25 Aug 2025 15:09:15 +0200 Subject: [PATCH 1/2] Replace UUIDGenerator implementation with Apache licensed code --- .../java/io/sentry/util/UUIDGenerator.java | 74 +++++++++---------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/sentry/src/main/java/io/sentry/util/UUIDGenerator.java b/sentry/src/main/java/io/sentry/util/UUIDGenerator.java index cbe90f96d83..1b39e94e527 100644 --- a/sentry/src/main/java/io/sentry/util/UUIDGenerator.java +++ b/sentry/src/main/java/io/sentry/util/UUIDGenerator.java @@ -1,26 +1,19 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * Adapted from: http://github.com/baomidou/dynamic-datasource/blob/bae2677b83abad549e3ddf41b286749515360e7b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/tx/LocalTxUtil.java * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * Copyright © 2018 organization baomidou * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.sentry.util; @@ -35,36 +28,41 @@ public final class UUIDGenerator { @SuppressWarnings("NarrowingCompoundAssignment") public static long randomHalfLengthUUID() { - Random random = SentryRandom.current(); + Random ng = SentryRandom.current(); byte[] randomBytes = new byte[8]; - random.nextBytes(randomBytes); - randomBytes[6] &= 0x0f; /* clear version */ - randomBytes[6] |= 0x40; /* set to version 4 */ - + ng.nextBytes(randomBytes); + // clear version + randomBytes[6] &= 0x0f; + // set to version 4 + randomBytes[6] |= 0x40; long msb = 0; - - for (int i = 0; i < 8; i++) msb = (msb << 8) | (randomBytes[i] & 0xff); - + for (int i = 0; i < 8; i++) { + msb = (msb << 8) | (randomBytes[i] & 0xff); + } return msb; } @SuppressWarnings("NarrowingCompoundAssignment") public static UUID randomUUID() { - Random random = SentryRandom.current(); + Random ng = SentryRandom.current(); byte[] randomBytes = new byte[16]; - random.nextBytes(randomBytes); - randomBytes[6] &= 0x0f; /* clear version */ - randomBytes[6] |= 0x40; /* set to version 4 */ - randomBytes[8] &= 0x3f; /* clear variant */ - randomBytes[8] |= (byte) 0x80; /* set to IETF variant */ - + ng.nextBytes(randomBytes); + // clear version + randomBytes[6] &= 0x0f; + // set to version 4 + randomBytes[6] |= 0x40; + // clear variant + randomBytes[8] &= 0x3f; + // set to IETF variant + randomBytes[8] |= 0x80; long msb = 0; long lsb = 0; - - for (int i = 0; i < 8; i++) msb = (msb << 8) | (randomBytes[i] & 0xff); - - for (int i = 8; i < 16; i++) lsb = (lsb << 8) | (randomBytes[i] & 0xff); - + for (int i = 0; i < 8; i++) { + msb = (msb << 8) | (randomBytes[i] & 0xff); + } + for (int i = 8; i < 16; i++) { + lsb = (lsb << 8) | (randomBytes[i] & 0xff); + } return new UUID(msb, lsb); } } From 499bbc6a784fa6aaf01b244381dd115f4779f455 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Wed, 27 Aug 2025 15:17:13 +0200 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 563997f9f2d..65f6d5947e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Add support for Spring Boot 4 and Spring 7 ([#4601](https://github.com/getsentry/sentry-java/pull/4601)) - NOTE: Our `sentry-opentelemetry-agentless-spring` is not working yet for Spring Boot 4. Please use `sentry-opentelemetry-agent` until OpenTelemetry has support for Spring Boot 4. +- Replace `UUIDGenerator` implementation with Apache licensed code ([#4662](https://github.com/getsentry/sentry-java/pull/4662)) ## 8.20.0