SupplierUtil.createSupplier returns a slow supplier
See original GitHub issueIssue
Calls getDeclaredConstructor every time.
Expected behaviour
Hoist the call to getDeclaredConstructor and close over it.
@Nonnull
public static <T> Supplier<T> createSupplier(Class<? extends T> edgeClass) {
try {
Constructor<? extends E> constructor = edgeClass.getDeclaredConstructor();
return () -> {
try {
return constructor.newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
};
} catch (ReflectiveOperationException | SecurityException e) {
throw new RuntimeException(e);
}
}
Conclusions
LOL another performance issue from those random idiots who are doing WTF? 😄 😄
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
SupplierUtil (JGraphT : a free Java graph library)
Create a long supplier which returns a sequence starting from a specific numbers. Create a string supplier which returns random UUIDs.
Read more >2023116 - How to Create a Supplier Return Without a Reference
Go to the Outbound Logistics work center; Go to the Common Tasks and select New Return to Supplier; You are not able to...
Read more >Is it possible to declare that a Supplier<T> needs to throw an ...
Considering the above, why not create a new interface and declare the getWithIO method in ... requireNonNull(supplier); try { return supplier.get(); } catch ......
Read more >Supplier Returns Without Receipts - Oracle Help Center
You can return goods to a supplier without referencing the original receipt. This is useful when returning goods with a receipt reference isn't...
Read more >Index (resilience4j-core 1.7.1 API) - javadoc.io
SupplierUtils. Returns a composed function that first applies the Supplier and then applies either the resultHandler or exceptionHandler.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am mostly concerned with stuff like adjusting permissions using reflection. I can certainly try testing the resulting code w.r.t AOT before we merge anything.
I tested AOT and there is no problem with this change.
Closing this one in favor of version with proper serialization (#821).