r/stackoverflow • u/FalseGround4533 • Jan 09 '25
Java Spring boot and cacheable method
Hi everyone, I need help.
I asked a question so if anyone knows the answer I would be grateful if you could help me. This is the link to my problem:
r/stackoverflow • u/FalseGround4533 • Jan 09 '25
Hi everyone, I need help.
I asked a question so if anyone knows the answer I would be grateful if you could help me. This is the link to my problem:
r/stackoverflow • u/Raam321 • Nov 05 '25
I am trying to implement an ordered list that inserts elements in the correct position using a Comparator<T>.
I have the following class:
public class ArrayOrderedList<T> extends ArrayList<T> implements OrderedListADT<T> {
private Comparator<T> comparator;
public ArrayOrderedList(Comparator<T> comp) {
this.comparator = comp;
}
u/Override
public void add(T element) {
if (count == array.length)
expandCapacity();
int i = 0;
while (i < count && comparator.compare(element, array[i]) > 0) {
i++;
}
for (int j = count; j > i; j--) {
array[j] = array[j - 1];
}
array[i] = element;
count++;
}
}This class extends a custom ArrayList that stores elements in an internal array:
public class ArrayList<T> implements ListADT<T> {
protected T[] array;
protected int count;
private static final int DEFAULT_CAPACITY = 10;
@SuppressWarnings("unchecked")
public ArrayList() {
array = (T[]) (new Object[DEFAULT_CAPACITY]);
count = 0;
}
}The problem is that when I run the code, I get a ClassCastException related to the internal array (Object[]) when comparing elements using the Comparator.
I have already tried adding Comparable<T> to the class declaration, but it did not solve the problem. I also do not want to use approaches involving Class<T> clazz, Array.newInstance, or reflection to create the generic array.
My question:
How can I keep the internal array generic (T[]) without causing a ClassCastException when using Comparator<T> to maintain the list ordered upon insertion?
r/stackoverflow • • Oct 18 '24
?
r/stackoverflow • u/usr404notfound • Nov 28 '24
Hi everyone,
I am working on a web scraping project using Playwright 1.48.0 with Java 8. Here's the approach I am taking, followed by the issue I'm encountering:
Context and Page Management per Thread:
In each thread:
Resource Cleanup: After all threads finish their work, I:
Despite this structured approach, I often run into the following exception:com.microsoft.playwright.PlaywrightException: Cannot find object to call __adopt__.
This exception seems to be related to how Playwright manages its internal objects and threading, but I can't pinpoint what's going wrong. The error is intermittent, which makes debugging even harder.
Any help or insights into what might be causing this issue would be greatly appreciated! If you’ve faced similar problems or have best practices for using Playwright with multithreading, I’d love to hear about it.
p.s., I have to stick with java 8 for now, and it has to be multi threaded.
Thanks in advance!
r/stackoverflow • u/AwarenessLeading9434 • Mar 17 '25
For my uni project I'm building an web app for organizing sport tournaments where users can create an account to register a team in tournament that an organizer creates.
I'm using React.js and Spring Boot.
Now I have a dilemma, I'm wondering if implementing web socket is an overkill for my situation.
Problem summary:
If guests can have an overview of all teams that have joined in the competition and in that moment a new team is added or an existing one is deleted should that change be immediately on the screen and should I implement it with Web Socket or useEffect is okay?