You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pk...@apache.org on 2024/11/18 10:27:04 UTC
(commons-compress) branch feature/remove-commons-lang updated (b56b2777c -> dffd19870)
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a change to branch feature/remove-commons-lang
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
from b56b2777c Fix style violations (2)
new 18a444297 Simplify `SystemProperties.getOsName()`
new dffd19870 Fix indentation
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../commons/compress/internal/lang3/ArrayFill.java | 20 ++++----
.../compress/internal/lang3/SystemProperties.java | 12 ++---
.../internal/lang3/reflect/FieldUtils.java | 58 +++++++++++-----------
3 files changed, 43 insertions(+), 47 deletions(-)
(commons-compress) 01/02: Simplify `SystemProperties.getOsName()`
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch feature/remove-commons-lang
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 18a4442972842ce8e456d49e0589acbe4bd14aef
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Mon Nov 18 11:26:04 2024 +0100
Simplify `SystemProperties.getOsName()`
---
.../commons/compress/internal/lang3/SystemProperties.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/internal/lang3/SystemProperties.java b/src/main/java/org/apache/commons/compress/internal/lang3/SystemProperties.java
index 2c56c78bf..77d850710 100644
--- a/src/main/java/org/apache/commons/compress/internal/lang3/SystemProperties.java
+++ b/src/main/java/org/apache/commons/compress/internal/lang3/SystemProperties.java
@@ -20,14 +20,10 @@ package org.apache.commons.compress.internal.lang3;
public final class SystemProperties {
- public static String getOsName() {
- try {
- return System.getProperty("os.name");
- } catch (final SecurityException e) {
- return null;
+ public static String getOsName() {
+ return System.getProperty("os.name");
}
- }
- private SystemProperties() {
- }
+ private SystemProperties() {
+ }
}
(commons-compress) 02/02: Fix indentation
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch feature/remove-commons-lang
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit dffd1987065f8eeb34a27c7fefa473d8a1400a9f
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Mon Nov 18 11:26:51 2024 +0100
Fix indentation
---
.../commons/compress/internal/lang3/ArrayFill.java | 20 ++++----
.../internal/lang3/reflect/FieldUtils.java | 58 +++++++++++-----------
2 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/internal/lang3/ArrayFill.java b/src/main/java/org/apache/commons/compress/internal/lang3/ArrayFill.java
index 8e3ccb685..e172cad2d 100644
--- a/src/main/java/org/apache/commons/compress/internal/lang3/ArrayFill.java
+++ b/src/main/java/org/apache/commons/compress/internal/lang3/ArrayFill.java
@@ -22,16 +22,16 @@ import java.util.Arrays;
public final class ArrayFill {
- public static int[] fill(final int[] a, final int val) {
- Arrays.fill(a, val);
- return a;
- }
+ public static int[] fill(final int[] a, final int val) {
+ Arrays.fill(a, val);
+ return a;
+ }
- public static byte[] fill(final byte[] a, final byte val) {
- Arrays.fill(a, val);
- return a;
- }
+ public static byte[] fill(final byte[] a, final byte val) {
+ Arrays.fill(a, val);
+ return a;
+ }
- private ArrayFill() {
- }
+ private ArrayFill() {
+ }
}
diff --git a/src/main/java/org/apache/commons/compress/internal/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/compress/internal/lang3/reflect/FieldUtils.java
index f43bd49a1..39494eab2 100644
--- a/src/main/java/org/apache/commons/compress/internal/lang3/reflect/FieldUtils.java
+++ b/src/main/java/org/apache/commons/compress/internal/lang3/reflect/FieldUtils.java
@@ -24,38 +24,38 @@ import java.lang.reflect.Field;
public final class FieldUtils {
- public static Object readField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
- requireNonNull(target, "target");
- requireNonNull(fieldName, "fieldName");
- final Class<?> cls = target.getClass();
- final Field field = getField(cls, fieldName, forceAccess);
- if (field == null) {
- throw new IllegalArgumentException(String.format("Cannot locate field %s on %s", fieldName, cls));
+ public static Object readField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
+ requireNonNull(target, "target");
+ requireNonNull(fieldName, "fieldName");
+ final Class<?> cls = target.getClass();
+ final Field field = getField(cls, fieldName, forceAccess);
+ if (field == null) {
+ throw new IllegalArgumentException(String.format("Cannot locate field %s on %s", fieldName, cls));
+ }
+ return field.get(target);
}
- return field.get(target);
- }
- private static Field getField(final Class<?> cls, final String fieldName, final boolean forceAccess) {
- requireNonNull(cls, "cls");
- requireNonNull(fieldName, "fieldName");
- Class<?> currentClass = cls;
- while (currentClass != null) {
- try {
- final Field field = currentClass.getDeclaredField(fieldName);
- // getDeclaredField checks for non-public scopes as well
- // and it returns accurate results
- if (forceAccess && !field.isAccessible()) {
- field.setAccessible(true);
+ private static Field getField(final Class<?> cls, final String fieldName, final boolean forceAccess) {
+ requireNonNull(cls, "cls");
+ requireNonNull(fieldName, "fieldName");
+ Class<?> currentClass = cls;
+ while (currentClass != null) {
+ try {
+ final Field field = currentClass.getDeclaredField(fieldName);
+ // getDeclaredField checks for non-public scopes as well
+ // and it returns accurate results
+ if (forceAccess && !field.isAccessible()) {
+ field.setAccessible(true);
+ }
+ return field;
+ } catch (final NoSuchFieldException ignored) {
+ // ignore
+ }
+ currentClass = currentClass.getSuperclass();
}
- return field;
- } catch (final NoSuchFieldException ignored) {
- // ignore
- }
- currentClass = currentClass.getSuperclass();
+ return null;
}
- return null;
- }
- private FieldUtils() {
- }
+ private FieldUtils() {
+ }
}