You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for example: String id=FieldUtils.getFieldValue(next, "id")
public class Base implements Serializable {
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
public class Son extends Base implements Serializable {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class TestCase {
public static void main(String[] args) {
List<Son> records = new ArrayList<>();
List<Son> records2 = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 1000; i++) {
long l = random.nextLong();
Son son = new Son();
son.setId(l + "");
records.add(son);
Son son2 = new Son();
son2.setId(l + "");
records2.add(son2);
}
new Thread(() -> {
Iterator<Son> iterator = records.iterator();
while (iterator.hasNext()) {
Son next = iterator.next();
String id = FieldUtils.getFieldValue(next, "id");
}
}).start();
new Thread(() -> {
Iterator<Son> iterator = records2.iterator();
while (iterator.hasNext()) {
Son next = iterator.next();
String id = FieldUtils.getFieldValue(next, "id");
}
}).start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Exception in thread "Thread-1" java.lang.IllegalStateException: Could not access method or field: Class org.springframework.util.ReflectionUtils can not access a member of class com.Base with modifiers "private"
at org.springframework.util.ReflectionUtils.handleReflectionException(ReflectionUtils.java:107)
at org.springframework.util.ReflectionUtils.getField(ReflectionUtils.java:652)
at com.alibaba.spring.util.FieldUtils.getFieldValue(FieldUtils.java:72)
at com.alibaba.spring.util.FieldUtils.getFieldValue(FieldUtils.java:28)
at com.TestCase.lambda$main$1(TestCase.java:41)
The text was updated successfully, but these errors were encountered:
for example: String id=FieldUtils.getFieldValue(next, "id")
Exception in thread "Thread-1" java.lang.IllegalStateException: Could not access method or field: Class org.springframework.util.ReflectionUtils can not access a member of class com.Base with modifiers "private"
at org.springframework.util.ReflectionUtils.handleReflectionException(ReflectionUtils.java:107)
at org.springframework.util.ReflectionUtils.getField(ReflectionUtils.java:652)
at com.alibaba.spring.util.FieldUtils.getFieldValue(FieldUtils.java:72)
at com.alibaba.spring.util.FieldUtils.getFieldValue(FieldUtils.java:28)
at com.TestCase.lambda$main$1(TestCase.java:41)
The text was updated successfully, but these errors were encountered: