-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_response_page_1.json
More file actions
2313 lines (2313 loc) · 445 KB
/
Copy pathapi_response_page_1.json
File metadata and controls
2313 lines (2313 loc) · 445 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"items" : [ {
"tags" : [ "java", "swing" ],
"owner" : {
"account_id" : 2470995,
"reputation" : 31,
"user_id" : 2152865,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/2308d14e8e2a408287b75d5f81fb8f47?s=256&d=identicon&r=PG",
"display_name" : "James Henderson",
"link" : "https://stackoverflow.com/users/2152865/james-henderson"
},
"is_answered" : false,
"view_count" : 12,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764997764,
"creation_date" : 1764987051,
"last_edit_date" : 1764997764,
"question_id" : 79839444,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79839444/java-resize-jframe-when-moving-to-new-screen",
"title" : "Java - Resize JFrame When Moving to New Screen",
"body" : "<p>I have two monitors with different resolutions. I would like for a <code>JFrame</code> to dynamically resize when dragged to a different monitor. This has proven surprisingly difficult.</p>\n<p>Here is a reproducible example.<br />\nWhen dragging to a new frame, the label will update, but the frame will not change size.\nI've tried various combinations of revalidation, repainting, everything I can think of.</p>\n<p>Any help is appreciated.</p>\n<pre class=\"lang-java prettyprint-override\"><code>import javax.swing.JFrame;\nimport javax.swing.JLabel;\nimport javax.swing.SwingUtilities;\nimport java.awt.Dimension;\nimport java.awt.GraphicsDevice;\nimport java.awt.event.ComponentEvent;\nimport java.awt.event.ComponentListener;\n\npublic class ResizeTest extends JFrame {\n private GraphicsDevice currentScreen;\n public ResizeTest() {\n currentScreen = getGraphicsConfiguration().getDevice();\n JLabel screenLabel = new JLabel(currentScreen.getIDstring());\n getContentPane().add(screenLabel);\n\n addComponentListener(new ComponentListener() {\n\n @Override\n public void componentResized(ComponentEvent e) {}\n\n @Override\n public void componentMoved(ComponentEvent e) {\n SwingUtilities.invokeLater(() -> {\n GraphicsDevice newScreen = getGraphicsConfiguration().getDevice();\n if(!newScreen.equals(currentScreen)) {\n currentScreen = newScreen;\n screenLabel.setText(currentScreen.getIDstring());\n setSize(new Dimension(getWidth(), (int) (currentScreen.getDisplayMode().getHeight() * 0.8)));\n revalidate();\n }\n });\n }\n\n @Override\n public void componentShown(ComponentEvent e) {}\n\n @Override\n public void componentHidden(ComponentEvent e) {}\n });\n }\n\n public static void main(String[] args) {\n SwingUtilities.invokeLater(() -> {\n ResizeTest frame = new ResizeTest();\n frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n frame.setSize(500, 500);\n frame.revalidate();\n frame.setLocationRelativeTo(null);\n frame.setVisible(true);\n });\n }\n}\n</code></pre>\n"
}, {
"tags" : [ "java", "spring", "aop", "aspectj", "jdbi" ],
"owner" : {
"account_id" : 5866617,
"reputation" : 21,
"user_id" : 4620361,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/05a0c824d2c6b767e9b8367544eb458c?s=256&d=identicon&r=PG",
"display_name" : "Vaent",
"link" : "https://stackoverflow.com/users/4620361/vaent"
},
"is_answered" : false,
"view_count" : 16,
"answer_count" : 0,
"score" : 2,
"last_activity_date" : 1764975961,
"creation_date" : 1764975961,
"question_id" : 79839373,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79839373/is-it-possible-to-inspect-method-invocations-on-a-jdbi-dao-using-aspect-oriented",
"title" : "Is it possible to inspect method invocations on a JDBI DAO using aspect-oriented programming?",
"body" : "<p>We mostly use <code>Jdbi.onDemand</code> with DAO interfaces to interact with our RDS.</p>\n<p>I'm trying to get visibility of when each DAO method is invoked.</p>\n<p>We have hundreds of methods across dozens of interfaces, so adding logs to every invocation individually is impractical.</p>\n<p>I was hoping to use an AOP advice based on JDBI annotations on the interface methods. We have <code>@annotation</code> advice for some controller methods, which works well, but the same approach isn't working for DAO methods.</p>\n<p>I suspect this is because both Spring AOP and JDBI work by creating proxy classes based on the interface, so that JDBI is able to get an instance and use it to interact with the database, but my aspect can't "see" that instance to apply the advice. I'm pretty new to this though and still getting my head round the details.</p>\n<p>Example code snippets (simplified):</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Service\npublic class MyService {\n private Jdbi jdbi;\n\n public Long getCount() {\n // MyDAO#getCount is invoked as expected\n return jdbi.onDemand(MyDAO.class).getCount();\n }\n}\n</code></pre>\n<pre class=\"lang-java prettyprint-override\"><code>public interface MyDAO {\n @SqlQuery("SELECT COUNT(*) FROM myschema.mytable")\n public Long getCount();\n}\n</code></pre>\n<pre class=\"lang-java prettyprint-override\"><code>@Aspect\n@Component\npublic class MyAspect {\n @Before("@annotation(sqlQuery)")\n public void queryAdvice(SqlQuery sqlQuery) {\n // When the service method is invoked, I expect this to be printed, but nothing happens\n System.out.println("Executing query: " + sqlQuery.value());\n }\n}\n</code></pre>\n<p>I've tried different advice types, different pointcut expressions including <code>bean</code> and <code>execution</code>, using a separate pointcut method, using a custom annotation instead of the JDBI one. Nothing I've tried seems to make any difference.</p>\n<p>Is there a workaround or a way to configure the aspect/interface so that JDBI's on-demand extension can interact with AspectJ/Spring AOP/any other aspect-oriented framework?</p>\n"
}, {
"tags" : [ "java", "spring-boot", "spring-mvc" ],
"owner" : {
"account_id" : 27077117,
"reputation" : 1,
"user_id" : 20626843,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a/ALm5wu1Y5nVvVqNH7H5TmKi_2OmYxBmk8rhsUAIFbF0B=k-s256",
"display_name" : "Udhayakumar T",
"link" : "https://stackoverflow.com/users/20626843/udhayakumar-t"
},
"is_answered" : false,
"view_count" : 23,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764959198,
"creation_date" : 1764959198,
"question_id" : 79839208,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79839208/from-which-package-do-i-import-webmvctest-in-spring-boot-4-x",
"title" : "From which package do I import @WebMvcTest in Spring Boot 4.x?",
"body" : "<pre class=\"lang-java prettyprint-override\"><code>import org.junit.jupiter.api.BeforeEach;\nimport org.junit.jupiter.api.Test;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;\nimport org.springframework.http.MediaType;\nimport org.springframework.test.context.bean.override.mockito.MockitoBean;\nimport org.springframework.test.web.servlet.MockMvc;\n\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.fasterxml.jackson.databind.module.SimpleModule;\n\n@WebMvcTest(ProfSrchRestService.class)\nclass ProfSrchRestServiceUnitTest {\n // test code\n}\n</code></pre>\n<p>VS code says:</p>\n<blockquote>\n<p>The import <code>org.springframework.boot.webmvc.test</code> cannot be resolved</p>\n</blockquote>\n<p>When I run the tests, I get the following:</p>\n<pre><code>[ERROR] TestEngine with ID 'junit-jupiter' failed to discover tests\n[INFO] \n[INFO] Results:\n[INFO]\n[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0\n[INFO]\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 01:21 min\n[INFO] Finished at: 2025-12-05T13:17:29+05:30\n[INFO] ------------------------------------------------------------------------\n[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.5.4:test (default-test) on project sdpco-cust-profile-search-svc:\n[ERROR]\n[ERROR] See C:\\Users\\UT001012134\\git\\4\\sdpco-cust-profile-search-svc\\target\\surefire-reports for the individual test results.\n[ERROR] See dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.\n[ERROR] There was an error in the forked process\n[ERROR] TestEngine with ID 'junit-jupiter' failed to discover tests\n[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process\n[ERROR] TestEngine with ID 'junit-jupiter' failed to discover tests\n[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:631) \n[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285) \n[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:250) \n[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1337)\n[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1135)\n[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:969)\n[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)\n[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328) \n[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316) \n[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) \n[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174) \n[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75) \n[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)\n[ERROR] at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)\n</code></pre>\n<p>I used this as reference: <a href=\"https://docs.spring.io/spring-boot/api/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTest.html\" rel=\"nofollow noreferrer\">https://docs.spring.io/spring-boot/api/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTest.html</a></p>\n<p>My pom has:</p>\n<pre class=\"lang-xml prettyprint-override\"><code><dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-webmvc</artifactId>\n</dependency>\n<dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-webmvc-test</artifactId>\n <scope>test</scope>\n</dependency>\n<dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n</dependency>\n<dependency>\n <groupId>org.junit.jupiter</groupId>\n <artifactId>junit-jupiter-api</artifactId>\n <version>6.0.1</version>\n <scope>test</scope>\n</dependency>\n</code></pre>\n<p>Am I doing the import correctly?</p>\n"
}, {
"tags" : [ "java", "spring", "gradle", "boot" ],
"owner" : {
"account_id" : 1534311,
"reputation" : 59,
"user_id" : 1430752,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/248d54f4af0ca39386c7eeaf8013acb9?s=256&d=identicon&r=PG",
"display_name" : "Al Harper",
"link" : "https://stackoverflow.com/users/1430752/al-harper"
},
"is_answered" : false,
"view_count" : 18,
"answer_count" : 1,
"score" : 0,
"last_activity_date" : 1764962823,
"creation_date" : 1764956361,
"question_id" : 79839168,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79839168/gradle-does-not-add-the-correct-main-class-entry-in-the-manifest-mf-file",
"title" : "Gradle does not add the correct main-class entry in the manifest.mf file",
"body" : "<p>I have tried for days now to get the Gradle build to produce a Spring Boot jar file that will run. Everything builds ok except for one thing. Gradle does not put the correct main-class entry in the manifest.mf file. It puts:</p>\n<pre><code>Main-Class: org.springframework.boot.loader.JarLauncher\ninstead of:\nMain-Class: org.springframework.boot.loader.PropertiesLauncher\n</code></pre>\n<p>in the manifest file. No matter what I've tried so far that Gradle accepts as a properly formatted build.gradle file, will produce a manifest.mf file with that one entry that I need the PropertiesLauncher class.</p>\n<p>I've tried every example I could fine with Google in my build.gradle file. It builds fine but refuses to add the correct main-class entry in the manifest.</p>\n<p>If I manually add the main-class entry in the file and splice it back into the jar everything work fine. My program launches just fine and everything is great. This is a multi-project Gradle build.</p>\n<p>The following is my gutted build.gradle. There is some possible proprietary stuff in it, and delete hopefully unnecessary stuff. I'm hopping there is enough here for analysis. If more is needed I might have to cough up more info. Hopefully most of what's needed is in the bootJar task.</p>\n<pre><code>import java.text.SimpleDateFormat\n\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.nio.file.StandardCopyOption;\nimport java.nio.file.StandardCopyOption\n\nplugins {\n// id 'org.springframework.boot' version '3.2.0'\n id 'application'\n id 'java'\n alias(libs.plugins.springBootPlugin)\n// alias(libs.plugins.springDependencyManagementPlugin)\n// id 'org.springframework.boot' version '3.2.0' // Apply the Spring Boot plugin\n id 'io.spring.dependency-management' version '1.1.4' // Recommended for managing Spring Boot dependencies\n}\n\napplication {\n mainClass = 'org.springframework.boot.loader.PropertiesLauncher' \n}\n//mainClassName = 'org.springframework.boot.loader.PropertiesLauncher'\n\njava {\n sourceCompatibility = JavaVersion.VERSION_1_8\n targetCompatibility = JavaVersion.VERSION_1_8\n}\n\napply plugin: 'org.springframework.boot'\n\next{\n group = rootProject.properties.get('groupId')\n// version = rootProject.properties.get('cupps.platform.version')\n}\n\nconfigurations {\n wrapperservice\n}\n\next {\n}\n\ndependencies {\n \n // The following JMX stuff does not exist on Maven anymore.\n // So we get them from maven-releases on our Nexus repository\n implementation 'com.sun.jmx:jmxri:1.2.1'\n implementation 'com.sun.jdmk:jmxtools:1.2.1'\n implementation 'javax.management:jmxremote:1.0.1_04'\n}\n\ntasks.named("compileJava") {\n}\n\n// To disable the standard 'jar' task if you only want the bootJar\njar {\n enabled = false\n}\n\n// Configuring the Main Class\n// https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#packaging-executable.configuring.main-class\ntasks.named("bootJar") {\n\n archiveFileName = "${artifactId}-${project.property('cupps.platform.version')}.jar" \n println "version2: " + "${artifactId}-${project.property('cupps.platform.version')}.jar" \n\n duplicatesStrategy = DuplicatesStrategy.EXCLUDE\n\n //mainClassName = 'com.arinc.afd.cupps.Application' // For Spring Boot Gradle Plugin version 2.6.x and above\n// mainClassName = 'org.springframework.boot.loader.PropertiesLauncher' // For Spring Boot Gradle Plugin version 2.5.x and below\n\n exclude ('**/batik*.*')\n exclude ('**/service-wrapper.zip')\n \n // To include the properties files, conf files, and xml file, etc under the resources folder into the JAR file.\n from sourceSets.main.resources\n\n// 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'\n\n manifest {\n attributes (\n 'Start-Class' : 'com.arinc.afd.cupps.Application',\n 'Built-By' : "${builtBy}",\n 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),\n 'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",\n 'Created-By' : "${createdBy}",\n 'Specification-Title' : "${specTitle}",\n 'Specification-Vendor' : "${specVendor}",\n 'Specification-Version' : "${specVersion}",\n 'Implementation-Title' : "${implementTitle}",\n 'Implementation-Vendor' : "${implementVendor}",\n 'Implementation-Version' : "${implementVersion}",\n )\n }\n}\n\n</code></pre>\n"
}, {
"tags" : [ "java", "spring-boot", "mockito" ],
"owner" : {
"account_id" : 16866055,
"reputation" : 11,
"user_id" : 12195739,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a-/AAuE7mAeLmW9XcQzHxvnxr8lzn-8SqbnNO6HxO5ydFp-5g=k-s256",
"display_name" : "Roman Gajardo Robles",
"link" : "https://stackoverflow.com/users/12195739/roman-gajardo-robles"
},
"is_answered" : false,
"view_count" : 36,
"answer_count" : 1,
"score" : 1,
"last_activity_date" : 1764959811,
"creation_date" : 1764951052,
"last_edit_date" : 1764957988,
"question_id" : 79839094,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79839094/classcastexception-monovoid-unit-test-java",
"title" : "ClassCastException Mono<Void> unit test Java",
"body" : "<p>i have the method in springboot that consume a endpoint</p>\n<pre class=\"lang-java prettyprint-override\"><code>public Mono<Void> mesaVisadoCalculadoraNotificar(NotificarIn in) {\n setTimeoutErrorCode("MVC-01");\n return Mono.fromCallable(() -> {\n WebTarget path = target.path(MesaVisadoCalculadora.NOTIFICAR.getUri());\n \n return restHelper.performRequest(path, in, new GenericType<Void>(){}, HttpAction.POST);\n });\n }\n}\n</code></pre>\n<p>and this test</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Test\npublic void mesavisadoCalculadoraNotificaTest(){\n when(target.path(Mockito.anyString())).thenReturn(target);\n when(restHelper.performRequest(Mockito.any(WebTarget.class), Mockito.any(), Mockito.any(GenericType.class),Mockito.any(HttpAction.class))).thenReturn(Mono.empty());\n\n Mono<Void> promise = agent.mesaVisadoCalculadoraNotificar(in);\n promise.block()\n Assertions.assertNotNull(promise);\n \n\n}\n</code></pre>\n<p>but in the line promise.block() return ClassCastException, any idea what it might be,</p>\n<p>this is a error in console:</p>\n<pre class=\"lang-none prettyprint-override\"><code>MesavisadoCalculadoraAgentTest > mesavisadoCalculadoraNotificaTest() FAILED\n java.lang.ClassCastException at MesavisadoCalculadoraAgentTest.java:65\n\njava.lang.ClassCastException: reactor.core.publisher.MonoIgnorePublisher cannot be cast to java.lang.Void\n at infrastructure.agent.apimesavisadocalculadora.MesaVisadoCalculadoraAgent.lambda$mesaVisadoCalculadoraNotificar$0(MesaVisadoCalculadoraAgent.java:45)\n at reactor.core.publisher.MonoCallable.block(MonoCallable.java:81)\n at reactor.core.publisher.MonoCallable.block(MonoCallable.java:74)\n at infrastructure.agent.apimesavisadocalculadora.MesavisadoCalculadoraAgentTest.mesavisadoCalculadoraNotificaTest(MesavisadoCalculadoraAgentTest.java:65)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:498)\n at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)\n at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)\n</code></pre>\n"
}, {
"tags" : [ "java", "mockito", "junit5", "jboss-arquillian", "payara-micro" ],
"owner" : {
"account_id" : 26036770,
"reputation" : 42,
"user_id" : 19742116,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/0b8eb1099efac9225080681c728f5c64?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Albert Albatros",
"link" : "https://stackoverflow.com/users/19742116/albert-albatros"
},
"is_answered" : false,
"view_count" : 20,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764950125,
"creation_date" : 1764950125,
"question_id" : 79839079,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79839079/caused-by-java-lang-classnotfoundexception-org-mockito-internal-creation-byteb",
"title" : "Caused by: java.lang.ClassNotFoundException: org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher",
"body" : "<p>I have integration tests configured in my project with payara-micro-managed, arquillian, and junit5. Everything works fine until I use Mockito. I get this error:</p>\n<pre><code>[2025-12-05T14:58:04.760+0000] [] [&amp#27;[1;93mWARNING&amp#27;[0m] [] [&amp#27;[1;94mjakarta.enterprise.web&amp#27;[0m] [tid: _ThreadID=77 _ThreadName=http-thread-pool::http-listener(1)] [timeMillis: 1764946684760] [levelValue: 900] [[\n StandardWrapperValve[ArquillianServletRunnerEE9]: Servlet.service() for servlet ArquillianServletRunnerEE9 threw exception\norg.jboss.weld.exceptions.WeldException\n at org.jboss.weld.module.ejb.SessionBeanProxyInstantiator.newInstance(SessionBeanProxyInstantiator.java:69)\n at org.jboss.weld.module.ejb.SessionBeanImpl.create(SessionBeanImpl.java:157)\n at org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:64)\n at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:106)\n at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)\n at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:706)\n at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:813)\n at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:93)\n at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:357)\n at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:368)\n at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:70)\n at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:245)\n at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:47)\n at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)\n at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:126)\n at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:165)\n at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)\n at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:106)\n at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:192)\n at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)\n at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:101)\n at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:136)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211)\n at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)\n at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:166)\n at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757)\n at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577)\n at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)\n at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158)\n at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:372)\n at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:239)\n at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)\n at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)\n at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)\n at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)\n at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)\n at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)\n at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)\n at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)\n at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)\n at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)\n at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)\n at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)\n at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)\n at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)\n at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)\n at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)\n at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)\n at java.base/java.lang.Thread.run(Thread.java:1583)\nCaused by: java.lang.reflect.InvocationTargetException\n at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)\n at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)\n at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)\n at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:40)\n at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)\n at org.jboss.weld.module.ejb.SessionBeanProxyInstantiator.newInstance(SessionBeanProxyInstantiator.java:55)\n ... 55 more\nCaused by: java.lang.NoClassDefFoundError: org/mockito/internal/creation/bytebuddy/inject/MockMethodDispatcher\n at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)\n ... 60 more\nCaused by: java.lang.ClassNotFoundException: org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher\n ... 64 more\n</code></pre>\n<p>I don't understand why I get this error even though I have the mockito-core library.\nMy configuration looks like this:</p>\n<blockquote>\n<p>maven profile for building payara micro jar and running tests</p>\n</blockquote>\n<pre><code> <profile>\n <id>build-test-microbundle</id>\n <build>\n <plugins>\n <plugin>\n <groupId>fish.payara.maven.plugins</groupId>\n <artifactId>payara-micro-maven-plugin</artifactId>\n <executions>\n <execution>\n <id>create-microbundle</id>\n <phase>package</phase>\n <goals>\n <goal>bundle</goal>\n </goals>\n </execution>\n </executions>\n <configuration>\n <payaraVersion>${payaraVersion}</payaraVersion>\n <payaraMicroAbsolutePath>\n target/microbundle.jar\n </payaraMicroAbsolutePath>\n <deployWar>false</deployWar>\n\n <customJars>\n <artifactItem>\n <groupId>net.bytebuddy</groupId>\n <artifactId>byte-buddy-agent</artifactId>\n </artifactItem>\n <artifactItem>\n <groupId>net.bytebuddy</groupId>\n <artifactId>byte-buddy</artifactId>\n </artifactItem>\n <artifactItem>\n <groupId>org.mockito</groupId>\n <artifactId>mockito-core</artifactId>\n </artifactItem>\n </customJars>\n </configuration>\n </plugin>\n </plugins>\n </build>\n </profile>\n <profile>\n <id>integration-test</id>\n <build>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-surefire-plugin</artifactId>\n <configuration>\n <systemPropertyVariables>\n <arquillian.launch>payara-micro-managed</arquillian.launch>\n </systemPropertyVariables>\n <includes>\n <include>**/*IntegrationTest.java</include>\n </includes>\n </configuration>\n </plugin>\n </plugins>\n </build>\n </profile>\n</code></pre>\n<blockquote>\n<p>arquillian.xml</p>\n</blockquote>\n<pre><code><arquillian xmlns="http://jboss.org/schema/arquillian"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://jboss.org/schema/arquillian\n http://jboss.org/schema/arquillian/arquillian_1_0.xsd">\n\n <container qualifier="payara-micro-managed" default="true">\n <configuration>\n <property name="microJar">target/microbundle.jar</property>\n <property name="autoBindHttp">true</property>\n <property name="clusterEnabled">false</property>\n\n </configuration>\n </container>\n</arquillian>\n</code></pre>\n<blockquote>\n<p>@Deployment method</p>\n</blockquote>\n<pre><code> @Deployment\n public static WebArchive getArchive() {\n WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");\n war.addPackages(true, "com.example");\n war.addAsLibraries(Maven.resolver()\n .loadPomFromFile("pom.xml")\n .importDependencies(ScopeType.COMPILE, ScopeType.TEST)\n .resolve()\n .withTransitivity()\n .asFile());\n\n return war;\n }\n</code></pre>\n<blockquote>\n<p>Test</p>\n</blockquote>\n<pre><code> @Test\n public void testResolveActionWithoutRedirectNavigationParameters() {\n Action action = Mockito.mock(Action.class);\n assertNotNull(action);\n }\n\n</code></pre>\n<blockquote>\n<p>Dependencies</p>\n</blockquote>\n<pre><code> <dependency>\n <groupId>org.mockito</groupId>\n <artifactId>mockito-core</artifactId>\n <version>5.15.2<version>\n </dependency>\n <dependency>\n <groupId>fish.payara.arquillian</groupId>\n <artifactId>arquillian-payara-micro-managed</artifactId>\n <version>4.0.alpha4</version>\n <scope>test</scope>\n </dependency>\n <dependency>\n <groupId>org.jboss.arquillian.junit5</groupId>\n <artifactId>arquillian-junit5-container</artifactId>\n <version>1.7.0.Final</version>\n <scope>test</scope>\n </dependency>\n <dependency>\n <groupId>org.jboss.arquillian.protocol</groupId>\n <artifactId>arquillian-protocol-servlet</artifactId>\n <version>1.7.0.Final</version>\n <scope>test</scope>\n </dependency>\n</code></pre>\n<blockquote>\n<p>Im using payara 6.2025.11</p>\n</blockquote>\n"
}, {
"tags" : [ "java", "spring", "spring-boot", "apache-kafka", "spring-kafka" ],
"owner" : {
"account_id" : 16791300,
"reputation" : 133,
"user_id" : 12138892,
"user_type" : "registered",
"profile_image" : "https://lh4.googleusercontent.com/-ODgFgc7UbZs/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rdhwqpf7qo4hCZta5XwFE2nGRRB_A/s256-rj/photo.jpg",
"display_name" : "Mykyta Piddubskiy",
"link" : "https://stackoverflow.com/users/12138892/mykyta-piddubskiy"
},
"is_answered" : true,
"view_count" : 28,
"answer_count" : 1,
"score" : 1,
"last_activity_date" : 1764947235,
"creation_date" : 1764944254,
"question_id" : 79838989,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838989/spring-boot-kafka-batching-for-all-partitions",
"title" : "Spring boot Kafka batching for all partitions",
"body" : "<p>I have Spring Boot with Kafka batching and a topic with 3 partitions. For example, I want to have 1 batch with 100 records continuously if I have a lot of messages in the topic, but if I have a low rate, then I want my app to send me a batch with 100 records or to wait 10 seconds and send me as big batch as possible.<br />\nRight now, I have the following properties in my test app (concurrency is 1):</p>\n<pre><code>fetch-min-size: 60_000\nfetch-max-wait: 10_000\nmax-poll-records: 100\n</code></pre>\n<p>And the problem is that if I have 1 partition, it works fine, but if I create a topic with 3 partitions, I start getting 3 small batches with a 10-second interval each. I assume that the listener listens for partitions separately and does not combine messages from them.<br />\nIs it possible to achieve it without the creation of a custom implementation of a listener to cache the responses, probably, and then divide them by batch size? Or are there other solutions?</p>\n<p>This property does not help since I use it for now, but it creates just a delay between polls, and in case of a big queue, I process very slowly.</p>\n<pre><code>idle-between-polls\n</code></pre>\n"
}, {
"tags" : [ "java", "javafx", "javafx-8" ],
"owner" : {
"account_id" : 10187542,
"reputation" : 2677,
"user_id" : 20692967,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/NZSXm.jpg?s=256",
"display_name" : "Sergey Zolotarev",
"link" : "https://stackoverflow.com/users/20692967/sergey-zolotarev"
},
"is_answered" : true,
"view_count" : 47,
"answer_count" : 1,
"score" : 1,
"last_activity_date" : 1764968329,
"creation_date" : 1764937122,
"last_edit_date" : 1764954417,
"question_id" : 79838872,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838872/nested-javafx-services",
"title" : "Nested JavaFX Services",
"body" : "<p>Here's a simplistic form for "saving" DB connection settings.</p>\n<ol>\n<li>It has two fields: URL and password. Valid credentials are "test" and "test".</li>\n<li>It has two buttons: "Test connection" and "Save".</li>\n<li>"Test connection" attempts to connect using provided credentials (that is, imagine it does). If they are not, then the fields get outlined in red.</li>\n<li>"Save" first tests the connection and, if successful, saves the settings.</li>\n</ol>\n<p>Important: testing connection can be done clicking either button, but saving must be performed only on clicking "Save".</p>\n<h1>Approach #1</h1>\n<p>I can declare two separate <code>Service</code>s. It means the saving listener is not activated on testing. However, the connection failure handling (red outlining) must either be duplicated in the save listener or be missing (in my MRE it's missing). In the real application, the testing functionality belongs to a child component's scope (imagine the testing button would be inside some container with a tiny spinner to boot that reflected the test status, for example). It would be a bit weird if my form would be nosing around in the child component's scope repeating the same failure handling.</p>\n<pre class=\"lang-java prettyprint-override\"><code>import javafx.application.Application;\nimport javafx.concurrent.Service;\nimport javafx.concurrent.WorkerStateEvent;\nimport javafx.css.PseudoClass;\nimport javafx.geometry.Insets;\nimport javafx.geometry.Pos;\nimport javafx.scene.Parent;\nimport javafx.scene.Scene;\nimport javafx.scene.control.Button;\nimport javafx.scene.control.Label;\nimport javafx.scene.control.TextField;\nimport javafx.scene.layout.Background;\nimport javafx.scene.layout.BackgroundFill;\nimport javafx.scene.layout.CornerRadii;\nimport javafx.scene.layout.GridPane;\nimport javafx.scene.layout.HBox;\nimport javafx.scene.paint.Color;\nimport javafx.scene.text.Font;\nimport javafx.stage.Stage;\n\nimport java.net.URL;\nimport java.time.Duration;\nimport java.util.Optional;\n\n\npublic class FXServiceDemo extends Application {\n\n static TextField urlField;\n static TextField passwordField;\n\n @Override\n public void start(Stage primaryStage) {\n primaryStage.setScene(createScene());\n primaryStage.setTitle("DB Settings");\n primaryStage.show();\n }\n\n private Scene createScene() {\n Parent root = createRoot();\n Scene scene = new Scene(root);\n findStylesheet().ifPresent(s -> scene.getStylesheets().add(s));\n return scene;\n }\n\n private static Optional<String> findStylesheet() {\n URL nullableStylesheet = FXServiceDemo.class.getResource("/styles/styles.css");\n Optional<URL> stylesheetOptional = Optional.ofNullable(nullableStylesheet);\n return stylesheetOptional.map(URL::toExternalForm);\n }\n\n private Parent createRoot() {\n GridPane root = new GridPane();\n root.setAlignment(Pos.CENTER);\n root.setPadding(new Insets(5));\n root.hgapProperty().set(5);\n root.vgapProperty().set(5);\n Label header = new Label("DB settings");\n header.setFont(Font.font(20));\n root.add(header, 0, 0, 2, 1);\n root.addRow(1, new Label("URL"), urlField = new TextField());\n root.addRow(2, new Label("Password"), passwordField = new TextField());\n root.add(createButtonRow(), 1, 3, 2, 1);\n return root;\n }\n\n private HBox createButtonRow() {\n HBox row = new HBox();\n row.setSpacing(5);\n row.setAlignment(Pos.CENTER_RIGHT);\n row.getChildren().add(createTestConnectionButton());\n row.getChildren().add(createSaveButton());\n return row;\n }\n\n Service<Void> testConnectionService = Services.from(this::testConnection);\n private Button createTestConnectionButton() {\n Button button = new Button();\n button.textProperty().set("Test Connection");\n button.setOnAction(e -> testConnectionService.restart());\n button.disableProperty().bind(testConnectionService.runningProperty());\n testConnectionService.addEventHandler(WorkerStateEvent.WORKER_STATE_SUCCEEDED, FXServiceDemo::onConnectionSuccess);\n testConnectionService.addEventHandler(WorkerStateEvent.WORKER_STATE_FAILED, FXServiceDemo::onConnectionFailure);\n return button;\n }\n\n private static void onConnectionSuccess(WorkerStateEvent e) {\n setValid(true);\n System.out.println("Connection was not established.");\n }\n\n private static void onConnectionFailure(WorkerStateEvent e) {\n setValid(false);\n System.out.println("Connection was not established.");\n }\n\n private static void setValid(boolean valid) {\n PseudoClass invalid = PseudoClass.getPseudoClass("invalid");\n urlField.pseudoClassStateChanged(invalid, !valid);\n passwordField.pseudoClassStateChanged(invalid, !valid);\n }\n\n Service<Void> saveSettingsService = Services.from(this::saveSettings);\n private Button createSaveButton() {\n Button button = new Button();\n button.textFillProperty().set(Color.WHITE);\n button.backgroundProperty().set(new Background(new BackgroundFill(Color.GREEN, new CornerRadii(3), null)));\n button.textProperty().set("Save");\n button.setOnAction(e -> saveSettingsService.restart());\n button.disableProperty().bind(testConnectionService.runningProperty().or(saveSettingsService.runningProperty()));\n saveSettingsService.addEventHandler(WorkerStateEvent.WORKER_STATE_SUCCEEDED, FXServiceDemo::onSaveSuccess);\n saveSettingsService.addEventHandler(WorkerStateEvent.WORKER_STATE_FAILED, FXServiceDemo::onSaveFailure);\n return button;\n }\n\n private static void onSaveSuccess(WorkerStateEvent e) {\n System.out.println("Connection settings successfully saved.");\n }\n\n private static void onSaveFailure(WorkerStateEvent e) {\n System.out.println("Connection settings could not saved.");\n }\n\n private void testConnection() {\n System.out.println("Testing connection...");\n sleep(Duration.ofSeconds(1));\n if (credentialsValid()) return;\n throw new IllegalArgumentException("Invalid Credentials");\n }\n\n private boolean credentialsValid() {\n String correctUrl = "test";\n String correctPass = "test";\n return correctUrl.equals(urlField.textProperty().get()) &&\n correctPass.equals(passwordField.textProperty().get());\n }\n\n private void saveSettings() {\n testConnection();\n System.out.println("Saving connection settings...");\n sleep(Duration.ofSeconds(1));\n }\n\n private static void sleep(Duration duration) {\n try {\n Thread.sleep(duration.toMillis());\n } catch (InterruptedException e) {\n throw new RuntimeException(e);\n }\n }\n}\n</code></pre>\n<pre class=\"lang-none prettyprint-override\"><code>import javafx.concurrent.Service;\nimport javafx.concurrent.Task;\n\npublic class Services {\n\n public static Service<Void> from(Runnable task) {\n return new Service<Void>() {\n @Override\n protected Task<Void> createTask() {\n return new Task<Void>() {\n @Override\n protected Void call() {\n task.run();\n return null;\n }\n };\n }\n };\n }\n}\n</code></pre>\n<pre class=\"lang-css prettyprint-override\"><code>/* resources/styles/styles.css */\n\n.text-field:invalid {\n -fx-border-color : salmon;\n}\n</code></pre>\n<p><a href=\"https://i.sstatic.net/F0BDQRWV.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.sstatic.net/F0BDQRWV.png\" alt=\"enter image description here\" /></a></p>\n<h1>Approach #2</h1>\n<p>I can declare one <code>Service</code>. Then failure handling will be executed no matter which button triggers it. However, testing connection will then notify the same saving listener (since listeners would also be shared). In effect, it would mean the testing button would be saving as well — unacceptable.</p>\n<h1>Approach #3</h1>\n<p><strong>(theoretical)</strong></p>\n<p>If I could:</p>\n<ol>\n<li>Declare two separate services.</li>\n<li>But have the saving service "contain" the lifecycle of the testing service.</li>\n</ol>\n<p>I could meet all of my requirements.</p>\n<p>However, it seems, I can't have nested <code>Service</code>s in JavaFX.</p>\n<h1>Approach #4</h1>\n<p><strong>(theoretical)</strong></p>\n<p>I could call some <code>restartAndThen(resultConsumer)</code> method that would register no additional listeners but execute a one-off callback on that particular invocation – the invocation performed by the saving button's action listener.</p>\n<p>Again, it's imaginary. No such API exists.</p>\n<p>How do I achieve my goals?</p>\n<p>Java 8.</p>\n"
}, {
"tags" : [ "java" ],
"owner" : {
"account_id" : 44916351,
"reputation" : 1,
"user_id" : 32003327,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/3e767d39f71ec86b8b027b29e1235790?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Prathap Reddy",
"link" : "https://stackoverflow.com/users/32003327/prathap-reddy"
},
"is_answered" : false,
"view_count" : 15,
"closed_date" : 1764944421,
"answer_count" : 0,
"score" : -2,
"last_activity_date" : 1764936879,
"creation_date" : 1764936879,
"question_id" : 79838871,
"link" : "https://stackoverflow.com/questions/79838871/webclient-exception-pkix-path-building",
"closed_reason" : "Not suitable for this site",
"title" : "Webclient Exception : PKIX path building",
"body" : "<p>pkix path building failed when i call target server API from java application code where target server gave me PEM and key and passphrase</p>\n"
}, {
"tags" : [ "java", "ssl", "ssl-certificate", "webclient", "x509" ],
"owner" : {
"account_id" : 17055723,
"reputation" : 9,
"user_id" : 12340316,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a-/AAuE7mBH-gYLjUbWYhJhZACOMh1Z2a76ie3ni_oEmERvGuk=k-s256",
"display_name" : "Arpit Sharma",
"link" : "https://stackoverflow.com/users/12340316/arpit-sharma"
},
"is_answered" : false,
"view_count" : 45,
"answer_count" : 3,
"score" : 0,
"last_activity_date" : 1764953119,
"creation_date" : 1764930290,
"question_id" : 79838766,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838766/pkix-path-building-failed-unable-to-find-valid-certification-path-how-to-load",
"title" : "PKIX path building failed: unable to find valid certification path — How to load PEM certificate into truststore at runtime in Spring Boot?",
"body" : "<p>I am getting the below SSL error when my Java (Java 21, Spring Boot 3/4) application makes a REST call to a gateway:</p>\n<pre><code>Internal server error: (certificate_unknown) PKIX path building failed: \nsun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target\n</code></pre>\n<p>I already have the server certificate in a <code>.pem</code> file (X.509 certificate).<br />\nExample format:</p>\n<pre class=\"lang-none prettyprint-override\"><code>-----BEGIN CERTIFICATE-----\nMIIGmjCCBYKgAwIBAgIT...\n-----END CERTIFICATE-----\n</code></pre>\n<p>My Java application needs to trust this certificate when calling the Gateway.<br />\nThe Gateway requires certificate pinning — if the cert is not trusted, the request fails immediately.</p>\n<p>When my Java/Spring application starts:</p>\n<ol>\n<li><p><strong>Load this PEM certificate</strong> from <code>resources/certs/certificate.pem</code></p>\n</li>\n<li><p><strong>Add it to an in-memory truststore (JKS or PKCS12)</strong> at runtime</p>\n</li>\n<li><p><strong>Use that truststore for all outbound REST calls</strong> (WebClient / RestTemplate)</p>\n</li>\n<li><p>I do <em>not</em> want to modify the JVM default <code>cacerts</code>.</p>\n</li>\n<li><p>I want the application itself to load & trust only the pinned certificate.</p>\n</li>\n</ol>\n<h3>What I have tried</h3>\n<p>I tried manually loading the cert:</p>\n<pre class=\"lang-java prettyprint-override\"><code>CertificateFactory cf = CertificateFactory.getInstance("X.509");\nX509Certificate cert = (X509Certificate) cf.generateCertificate(new FileInputStream("uidai_public.pem"));\n</code></pre>\n<p>This loads successfully, but configuring it into SSLContext is failing.</p>\n<p>My WebClient configuration attempts:</p>\n<pre class=\"lang-java prettyprint-override\"><code>TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());\ntmf.init(myKeystore);\nSSLContext sslContext = SSLContext.getInstance("TLS");\nsslContext.init(null, tmf.getTrustManagers(), null);\n</code></pre>\n<p>But unless the certificate is in a real truststore file, Spring throws the same <code>PKIX path building failed</code>.</p>\n<h3>Question</h3>\n<p><strong>How do I correctly:</strong></p>\n<ul>\n<li><p>Load an X.509 PEM certificate inside <code>src/main/resources</code></p>\n</li>\n<li><p>Programmatically create an in-memory truststore</p>\n</li>\n<li><p>Register that truststore with <code>WebClient</code> (or <code>HttpClient</code>) so that only that certificate is trusted?</p>\n</li>\n<li><p>Ensure that calls to the Gateway no longer fail with PKIX errors?</p>\n</li>\n</ul>\n<h3>Constraints</h3>\n<ul>\n<li><p>Java 21</p>\n</li>\n<li><p>Spring Boot 3.4.x / 4.x</p>\n</li>\n<li><p>Certificate is a <code>.pem</code> file containing a full X.509 certificate (NOT a public key only)</p>\n</li>\n<li><p>Application runs inside a container, so I cannot manually modify <code>/etc/ssl/certs</code> or JVM <code>cacerts</code></p>\n</li>\n</ul>\n"
}, {
"tags" : [ "java", "compilation", "jvm", "dynamic-compilation" ],
"owner" : {
"account_id" : 44915103,
"reputation" : 1,
"user_id" : 32002554,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/vgiXro7C.jpg?s=256",
"display_name" : "Basta Youssef",
"link" : "https://stackoverflow.com/users/32002554/basta-youssef"
},
"is_answered" : false,
"view_count" : 44,
"answer_count" : 0,
"score" : -1,
"last_activity_date" : 1764928458,
"creation_date" : 1764928458,
"question_id" : 79838729,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838729/jvm-escape-analysis-stack-allocation",
"title" : "JVM – Escape Analysis & Stack Allocation",
"body" : "<p>How can I reliably determine whether the JVM is performing stack allocation through Escape Analysis for a specific object inside a hot method, and how can I verify it at runtime using JIT logs or JFR?</p>\n"
}, {
"tags" : [ "java", "circuit-breaker", "resilience4j" ],
"owner" : {
"account_id" : 44915104,
"reputation" : 1,
"user_id" : 32002555,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/95b8b5e4e10e3dd94b8d7e6ff1adedc9?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Demotivational Speaker",
"link" : "https://stackoverflow.com/users/32002555/demotivational-speaker"
},
"is_answered" : false,
"view_count" : 19,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764998348,
"creation_date" : 1764928325,
"last_edit_date" : 1764998348,
"question_id" : 79838727,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838727/circuitbreaker-is-going-to-open-state-from-closed-before-minimumnumberofcalls",
"title" : "CircuitBreaker is going to OPEN state from CLOSED before minimumNumberOfCalls",
"body" : "<p>I'm using custom configuration for the <code>CircuitBreaker</code>:</p>\n<pre class=\"lang-java prettyprint-override\"><code>CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom()\n .failureRateThreshold(50)\n .slowCallDurationThreshold(60000)\n .permittedNumberOfCallsInHalfOpenState(5)\n .slidingWindowSize(10)\n .minimumNumberOfCalls(10)\n .build();\n</code></pre>\n<p>According the above code I should get <code>CallNotPermittedException</code> only after ten calls, but I'm getting at 6<sup>th</sup> call.<br />\nI've checked it's not <code>slowCall</code>.<br />\nFYI: I'm using Resilince4j 2.3.0, and its COUNT_BASED window.<br />\nWhat could be the reason ?</p>\n"
}, {
"tags" : [ "java", "spring", "spring-boot" ],
"owner" : {
"account_id" : 2314234,
"reputation" : 261,
"user_id" : 2031618,
"user_type" : "registered",
"accept_rate" : 93,
"profile_image" : "https://i.sstatic.net/X28tD.jpg?s=256",
"display_name" : "Bobby Akyong",
"link" : "https://stackoverflow.com/users/2031618/bobby-akyong"
},
"is_answered" : true,
"view_count" : 76,
"closed_date" : 1765002740,
"accepted_answer_id" : 79838749,
"answer_count" : 1,
"score" : 1,
"last_activity_date" : 1764960843,
"creation_date" : 1764926718,
"last_edit_date" : 1764960843,
"question_id" : 79838704,
"link" : "https://stackoverflow.com/questions/79838704/spring-boot-4-x-need-manual-inject-for-objectmapper-jackson",
"closed_reason" : "Not suitable for this site",
"title" : "Spring Boot 4.x need manual inject for ObjectMapper Jackson?",
"body" : "<p>Will Spring Boot 4 not inject a bean for Jackson automatically?</p>\n<p>I'm getting an error like this, given below:</p>\n<pre><code>\nAction:\n\nConsider defining a bean of type 'com.fasterxml.jackson.databind.ObjectMapper' in your configuration.\n\n\nProcess finished with exit code 0\n\n</code></pre>\n<p>I did configure the ObjectMapper Bean manually in my app for now:</p>\n<pre><code> @Bean\n public ObjectMapper objectMapper() {\n return new ObjectMapper();\n }\n</code></pre>\n<p>Take a look at <a href=\"https://github.com/akyong/SpringBoot4-MVC-MYSQL-cRUD/blob/main/src/main/java/com/bobbyakyong/spring_mvc_crud_mysql/SpringMvcCrudMysqlApplication.java\" rel=\"nofollow noreferrer\">Github</a></p>\n"
}, {
"tags" : [ "java", "sonarqube" ],
"owner" : {
"account_id" : 10465788,
"reputation" : 13482,
"user_id" : 7715250,
"user_type" : "registered",
"accept_rate" : 74,
"profile_image" : "https://www.gravatar.com/avatar/4218136fceb989e7e6c1c7e549267b07?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "J. Doe",
"link" : "https://stackoverflow.com/users/7715250/j-doe"
},
"is_answered" : false,
"view_count" : 20,
"closed_date" : 1764922250,
"answer_count" : 0,
"score" : -3,
"last_activity_date" : 1764934733,
"creation_date" : 1764920792,
"last_edit_date" : 1764934733,
"question_id" : 79838637,
"link" : "https://stackoverflow.com/questions/79838637/turn-off-coverage-for-certain-lines-in-java",
"closed_reason" : "Duplicate",
"title" : "Turn off coverage for certain lines in Java",
"body" : "<p>I am using SonarQube and this is in the report:</p>\n<p><img src=\"https://i.sstatic.net/4h8d1R1L.png\" alt=\"enter image description here\" /></p>\n<p>It doesn't make sense it shows that annotation in the first place. I tried turning the coverage off with configuration and adding the comments, like:</p>\n<pre class=\"lang-ini prettyprint-override\"><code>sonar.issue.ignore.block=e2\nsonar.issue.ignore.block.e2.beginBlockRegexp=@sonar-ignore\nsonar.issue.ignore.block.e2.endBlockRegexp=@end\n</code></pre>\n<p>That didn't work, below also doesn't work after adding it to a lombok.config file:</p>\n<pre class=\"lang-ini prettyprint-override\"><code>config.stopBubbling = true\nlombok.addLombokGeneratedAnnotation = true\n</code></pre>\n<p>Any suggestions? I have other blocks of code I also want to exclude. In the UI it doesn't seem like this is possible (my preference is in the code itself).</p>\n"
}, {
"tags" : [ "java", "android", "bluetooth", "hc-05" ],
"owner" : {
"account_id" : 44408219,
"reputation" : 1,
"user_id" : 31737120,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/65YstSoB.png?s=256",
"display_name" : "Claudiu",
"link" : "https://stackoverflow.com/users/31737120/claudiu"
},
"is_answered" : false,
"view_count" : 39,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764920002,
"creation_date" : 1764919909,
"last_edit_date" : 1764920002,
"question_id" : 79838627,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838627/i-cannot-connect-to-my-hc-05-bluetooth-module-using-my-own-java-app",
"title" : "I cannot connect to my HC-05 bluetooth module using my own Java app",
"body" : "<p>I built a Java app where I implemented bluetooth functionality. Using the documentation I managed to discover devices and pair with them. I managed to get the whole device info (address, name), but it fails when I want to establish communication with the module.</p>\n<p><strong>In the ConnectThread constructor:</strong></p>\n<pre><code>if (ContextCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {\n try {\n tmp = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));\n } catch (IOException e) {\n Log.e(TAG, "Socket's create() method failed", e);\n }\n } else {\n Log.e(TAG, "Missing BLUETOOTH_CONNECT permission");\n }\n targetSocket = tmp;\n</code></pre>\n<p><strong>In the ConnectThread method run():</strong></p>\n<pre><code>bluetoothAdapter.cancelDiscovery();\n\ntry {\n targetSocket.connect();\n Log.i(TAG, "Connection successful!");\n} catch (IOException e) {\n Log.d(TAG, Log.getStackTraceString(e));\n Log.e(TAG, "Could not connect; closing socket", e);\n try {\n targetSocket.close();\n } catch (IOException e2) {\n Log.e(TAG, "Could not close the client socket", e2);\n }\n}\n</code></pre>\n<p><strong>In the MainActivity, when I choose a device from the paired devices list:</strong></p>\n<pre><code>ConnectThread connectThread = new ConnectThread(device, mBluetoothManager, MainActivity.this);\nconnectThread.start();\n</code></pre>\n<p>**<br />\nWhat I have in my LOGCAT**</p>\n<pre><code>ConnectThread com.example.carcontroller D java.io.IOException: read failed, socket might closed or timeout, read ret: -1\n at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:1170)\n at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:1188)\n at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:566)\n at com.example.carcontroller.ConnectThread.run(ConnectThread.java:50)\nConnectThread com.example.carcontroller E Could not connect; closing socket\n java.io.IOException: read failed, socket might closed or timeout, read ret: -1\n at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:1170)\n at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:1188)\n at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:566)\n at com.example.carcontroller.ConnectThread.run(ConnectThread.java:50)\n\n</code></pre>\n<p>Using the <strong><a href=\"https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal\" rel=\"nofollow noreferrer\">Serial Bluetooth Terminal</a></strong> from google play I managed to connect to my module and send data so I figure that the problem is on my end but I can't find any information about why this happens.</p>\n"
}, {
"tags" : [ "java", "concurrency", "javafx-8" ],
"owner" : {
"account_id" : 10187542,
"reputation" : 2677,
"user_id" : 20692967,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/NZSXm.jpg?s=256",
"display_name" : "Sergey Zolotarev",
"link" : "https://stackoverflow.com/users/20692967/sergey-zolotarev"
},
"is_answered" : false,
"view_count" : 25,
"answer_count" : 1,
"score" : 0,
"last_activity_date" : 1764937440,
"creation_date" : 1764919905,
"last_edit_date" : 1764937440,
"question_id" : 79838626,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838626/binding-two-javafx-services-running-properties",
"title" : "Binding two JavaFX services' running properties",
"body" : "<p>How do I bind the <code>running</code> property of one <code>Service</code> to the same <code>property</code> of another <code>Service</code> that it (re)starts? The first service must be considered running as long as the "nested" service is. In my simple demo, there's only one nested service, yet there could be more.</p>\n<p>The problematic part is <code>service.runningProperty()</code> does not return a <code>javafx.beans.property.Property</code> with a <code>bind()</code> method. It instead returns a <code>ReadOnlyBooleanProperty</code> that does not expose such a method.</p>\n<p>I could override <code>javafx.concurrent.Service#runningProperty</code> in a subclass to return <code>super.runningProperty().or(nestedRunningProperty())</code>, but the method is <code>final</code>, could not be overridden.</p>\n<p>I am hesitant to declare a separate property in my <code>Service</code> subclass (say, <code>effectiveRunningProperty()</code>). I don't want the service's clients to even know whether it has nested services. I am fine with declaring <code>myService.addAndWire(anotherService)</code>, on the other hand, if necessary (may be called by another client beforehand, not the one requesting/ binding to the <code>running</code> property).</p>\n<p>What is the best way to achieve my goal?</p>\n<p>Here's a demo that does <strong>not</strong> achieve it. Its idea is to keep the "Start" button disabled as long as the service, in its entirety, is running.</p>\n<pre class=\"lang-java prettyprint-override\"><code>import javafx.application.Application;\nimport javafx.concurrent.Service;\nimport javafx.geometry.Insets;\nimport javafx.geometry.Pos;\nimport javafx.scene.Scene;\nimport javafx.scene.control.Button;\nimport javafx.scene.layout.VBox;\nimport javafx.stage.Stage;\n\nimport java.time.Duration;\nimport java.util.function.Function;\n\n\npublic class FXServiceDemo extends Application {\n\n @Override\n public void start(Stage primaryStage) {\n primaryStage.setScene(createScene());\n primaryStage.setTitle("Service Demo");\n primaryStage.show();\n }\n\n private Scene createScene() {\n VBox root = createRoot();\n Scene scene = new Scene(root);\n return scene;\n }\n\n private VBox createRoot() {\n VBox root = new VBox();\n root.setAlignment(Pos.CENTER);\n root.setPadding(new Insets(5));\n root.getChildren().add(createStartButton());\n return root;\n }\n\n private Button createStartButton() {\n Service<Void> outerService = createOuterService(); // inner Service is not create in this scope\n Button button = new Button();\n button.textProperty().set("Start");\n button.disableProperty().bind(outerService.runningProperty()); // button doesn't know there could be nested services\n Function<Boolean, String> toWord = disable -> disable ? "DISABLED" : "ENABLED";\n button.disableProperty().addListener((ob, ov, nv) -> System.out.printf("Button was %s, but is now %s\\n", toWord.apply(ov), toWord.apply(nv)));\n button.onActionProperty().setValue(e -> outerService.restart());\n return button;\n }\n\n private static Service<Void> createOuterService() {\n Service<Void> service = Services.from(FXServiceDemo::perform);\n return service;\n }\n\n private static void perform() {\n System.out.println("Doing something before launching the nested Service...");\n sleep(Duration.ofSeconds(1));\n System.out.println("Launching the nested Service...");\n startInnerService();\n }\n\n private static void startInnerService() {\n Service<Void> service = createInnerService();\n service.restart();\n }\n\n private static void sleep(Duration duration) {\n try {\n Thread.sleep(duration.toMillis());\n } catch (InterruptedException e) {\n throw new RuntimeException(e);\n }\n }\n\n private static Service<Void> createInnerService() {\n Service<Void> service = Services.from(FXServiceDemo::performNested);\n return service;\n }\n\n private static void performNested() {\n System.out.println("Doing something in the nested Service...");\n sleep(Duration.ofSeconds(2));\n System.out.println("Nested completed");\n }\n}\n</code></pre>\n<pre class=\"lang-java prettyprint-override\"><code>import javafx.concurrent.Service;\nimport javafx.concurrent.Task;\n\npublic class Services {\n\n public static Service<Void> from(Runnable task) {\n return new Service<Void>() {\n @Override\n protected Task<Void> createTask() {\n return new Task<Void>() {\n @Override\n protected Void call() {\n task.run();\n return null;\n }\n };\n }\n };\n }\n}\n</code></pre>\n<p>Once you run it and press the button, you get this console:</p>\n<pre><code>Button was ENABLED, but is now DISABLED \nDoing something before launching the nested Service...\nLaunching the nested Service...\nButton was DISABLED, but is now ENABLED \nDoing something in the nested Service...\nNested completed\n</code></pre>\n<p>Instead, it should be:</p>\n<pre><code>Button was ENABLED, but is now DISABLED \nDoing something before launching the nested Service...\nLaunching the nested Service...\nDoing something in the nested Service...\nNested completed\nButton was DISABLED, but is now ENABLED \n</code></pre>\n<p>Java 8.</p>\n"
}, {
"tags" : [ "java", "angular", "postgresql", "spring-boot" ],
"owner" : {
"account_id" : 44913844,
"reputation" : 1,
"user_id" : 32001765,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/d40fe08f1bcaab2b7b1b907c625f18e0?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Mlvin",
"link" : "https://stackoverflow.com/users/32001765/mlvin"
},
"is_answered" : true,
"view_count" : 58,
"answer_count" : 2,
"score" : 0,
"last_activity_date" : 1764920569,
"creation_date" : 1764918307,
"last_edit_date" : 1764918883,
"question_id" : 79838612,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838612/risks-of-using-java-25-lts-versus-java-21-lts-in-a-new-spring-boot-backend",
"title" : "Risks of using Java 25 LTS versus Java 21 LTS in a new Spring Boot backend",
"body" : "<p>I’m starting an inventory system: multi-branch, reporting, invoicing, which I plan to maintain for several years.</p>\n<p>Tentative stack:\nBackend: Java + Spring Boot\nDB: PostgreSQL\nInterface: Angular 21</p>\n<p>But I have some doubts about versions:\nJava:</p>\n<p>Option A: Java 21 LTS + Spring Boot 3.5\nOption B: Java 25 LTS + Spring Boot 3.5 or 4</p>\n<p>PostgreSQL:\n16, 17 or even 18 for this new project.</p>\n<p>And I’d like to clarify a few questions about the following:</p>\n<p>For a new backend with Spring Boot, what risks do you see in using Java 25 LTS instead of Java 21 (library compatibility, tooling, stability) as of today?</p>\n<p>For PostgreSQL, what criteria would you use to choose between 16, 17 or 18 in a CRUD-intensive inventory system? Is there any strong reason to avoid any of these versions in production right now?</p>\n"
}, {
"tags" : [ "java", "gwt" ],
"owner" : {
"account_id" : 4830465,
"reputation" : 207,
"user_id" : 3898783,
"user_type" : "registered",
"accept_rate" : 50,
"profile_image" : "https://www.gravatar.com/avatar/5461c373f57050efd35db91e0c0b3378?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "user3898783",
"link" : "https://stackoverflow.com/users/3898783/user3898783"
},
"is_answered" : false,
"view_count" : 23,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764915584,
"creation_date" : 1764915584,
"question_id" : 79838587,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838587/fields-are-not-showing-on-screen-after-upgrading-gwt-from-2-8-0-to-2-10-0-and-ja",
"title" : "Fields are not showing on screen after upgrading gwt from 2.8.0 to 2.10.0 and java 8 to 10",
"body" : "<p>Fields are not showing on screen after upgrading gwt from 2.8.0 to 2.10.0 and java 8 to 10. org.dominokit:domino-ui -> 1.0.7 and com.google.jsinterop:base -> 1.0.0.</p>\n<pre><code>MaterialWidget widget = new MaterialWidget(Document.get().createDivElement());\n</code></pre>\n<p>The above widget not loading in screen.</p>\n"
}, {
"tags" : [ "java", "apache-kafka" ],
"owner" : {
"account_id" : 34107195,
"reputation" : 1,
"user_id" : 26388899,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/f0d7a4f9e4fece58adbadf9beaa9d393?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Pallavi Ar",
"link" : "https://stackoverflow.com/users/26388899/pallavi-ar"
},
"is_answered" : false,
"view_count" : 17,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764945440,
"creation_date" : 1764912586,
"last_edit_date" : 1764945440,
"question_id" : 79838557,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838557/getting-duplicate-records-in-parquet-files-created-in-kafka-consumer",
"title" : "Getting duplicate records In Parquet files created In Kafka Consumer",
"body" : "<p>So when The consumer polls records after subscribing to kafka topic when the Very first parquet file created its has some offset entries but is creating a Huge file and when the next file created it has offset entries from previous files too so meaning that the latest File is having records from past entries why this duplicate records coming and until the batch is true we are not committing anything need solution to resolve the duplicate record issue</p>\n<p>Any Resolutions</p>\n<pre><code>try (KafkaConsumer<byte[], String> consumer = new KafkaConsumer<byte[], String>(props)) { \n LOGGER.info("subscribing to kafka topic.");\n consumer.subscribe(Arrays.asList(topic));\n\n ConsumerRecords<byte[], String> records;\n do {\n LOGGER.info("polling new records from kafka stream.");\n records = consumer.poll(Duration.ofMillis(10000));\n LOGGER.info("{} records returned.", records.count());\n\n for (ConsumerRecord<byte[], String> record : records) {\n JsonObject jsonObject = JsonParser.parseString(record.value()).getAsJsonObject();\n String payload = jsonObject.get("payload").getAsString();\n\n \n try (InputStream payloadIn = IOUtils.toInputStream(payload, StandardCharsets.US_ASCII)) {\n\n try (Base64InputStream base64In = new Base64InputStream(payloadIn)) {\n\n \n try (GZIPInputStream gzipIn = new GZIPInputStream(base64In)) {\n String xml = IOUtils.toString(gzipIn, StandardCharsets.UTF_8);\n\n writer.write(record.topic(), record.partition(), record.offset(), record.timestamp(), xml);\n }\n }\n }\n }\n\n LOGGER.info("records processed.");\n\n if (writer.endBatch()) {\n LOGGER.info("batch closed.");\n consumer.commitSync();\n LOGGER.info("batch committed.");\n }\n } while(true);\n } \n\npublic boolean endBatch() throws IOException { if (this.writer != null) { Instant now = Instant.now(); Duration elapsed = Duration.between(this.firstRecordTimestamp, now); if ( (this.maxRecordsPerFile > 0 && (this.recordCount % this.maxRecordsPerFile) == 0) || (this.maxCollectionDuration.compareTo(Duration.ZERO) > 0 && (elapsed.compareTo(this.maxCollectionDuration) >= 0)) ) { LOGGER.info("batch is complete either because of record limit or duration limit."); // the writer is full and should be closed. this.close(); return true; } }\n\n return false;\n} `\n</code></pre>\n"
}, {
"tags" : [ "java", "postgresql", "spring-boot", "hibernate", "testcontainers" ],
"owner" : {
"account_id" : 6099767,
"reputation" : 5261,
"user_id" : 4759176,
"user_type" : "registered",
"accept_rate" : 74,
"profile_image" : "https://i.sstatic.net/0U1e5.jpg?s=256",
"display_name" : "parsecer",
"link" : "https://stackoverflow.com/users/4759176/parsecer"
},
"is_answered" : true,
"view_count" : 54,
"accepted_answer_id" : 79838633,
"answer_count" : 2,
"score" : 2,
"last_activity_date" : 1764920667,
"creation_date" : 1764898227,
"question_id" : 79838482,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838482/testcontainer-h2-is-still-used-in-test-domain-text-not-found",
"title" : "Testcontainer: H2 is still used in test, Domain "TEXT" not found;",
"body" : "<p>I have a very simple example: the entity uses <code>TEXT</code> column and the test fails because of it, despite using PostgreSQL testcontainer:</p>\n<p><strong>application-test.properties</strong></p>\n<pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/testdb \nspring.datasource.username=postgres\nspring.datasource.password=postgres\nspring.jpa.hibernate.ddl-auto=create-drop\nspring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect\nspring.jpa.show-sql=true\nspring.jpa.properties.hibernate.jdbc.batch_size=0\n</code></pre>\n<p><strong>Dog.java</strong>:</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Entity\n@Getter\n@Setter\npublic class Dog {\n @Id\n @SequenceGenerator(name = "dog_sequence",\n sequenceName = "dog_sequence",\n allocationSize = 1)\n @GeneratedValue(strategy = GenerationType.SEQUENCE,\n generator = "dog_sequence")\n private Long id;\n\n @Column\n private String name;\n @Column(columnDefinition = "TEXT")\n private String description;\n\n}\n</code></pre>\n<p><strong>DogRepository.java</strong>:</p>\n<pre class=\"lang-java prettyprint-override\"><code>public interface DogRepository extends JpaRepository<Dog, Long> {}\n</code></pre>\n<p><strong>DogTest.java</strong>:</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Testcontainers\n@DataJpaTest\n@ActiveProfiles("test")\npublic class DogTest {\n @Container\n static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15.4")\n .withDatabaseName("testdb")\n .withUsername("postgres")\n .withPassword("postgres");\n\n @DynamicPropertySource\n static void overrideProperties(DynamicPropertyRegistry registry) {\n registry.add("spring.datasource.url", postgres::getJdbcUrl);\n registry.add("spring.datasource.username", postgres::getUsername);\n registry.add("spring.datasource.password", postgres::getPassword);\n registry.add("spring.datasource.driver-class-name", postgres::getDriverClassName);\n registry.add("spring.jpa.hibernate.ddl-auto", () -> "create-drop");\n registry.add("spring.jpa.database-platform", () -> "org.hibernate.dialect.PostgreSQLDialect");\n }\n\n\n @Autowired\n private DogRepository repository;\n\n @Autowired\n private TestEntityManager entityManager;\n\n\n @Before\n public void setUp() {\n for (int i = 0; i < 10; i++) {\n Dog dog = new Dog();\n entityManager.persist(dog);\n }\n\n entityManager.flush();\n }\n\n\n @Test\n public void testFindDogs() {\n List<Dog> dogs = repository.findAll();\n Assertions.assertEquals(1, dogs.size());\n\n }\n}\n</code></pre>\n<p>When I run the test I get the error:</p>\n<pre><code>Hibernate: \n create table "dog" (\n "id" bigint not null,\n "description" "TEXT",\n "name" varchar(255),\n primary key ("id")\n )\n2025-12-04T20:27:04.096-05:00 WARN 560907 --- [ main] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL "\n create table "dog" (\n "id" bigint not null,\n "description" "TEXT",\n "name" varchar(255),\n primary key ("id")\n )" via JDBC [Domain "TEXT" not found;]\n\norg.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "\n create table "dog" (\n "id" bigint not null,\n "description" "TEXT",\n "name" varchar(255),\n primary key ("id")\n )" via JDBC [Domain "TEXT" not found;]\n</code></pre>\n<p>From what I understand, <code>TEXT</code> is not used by <code>H2</code>, however works with <code>PostgreSQL</code>. It should work with PostgreSQL testcontainer, yet it doesn't, so it seems like the test is still using <code>H2</code>, and I don't see why.</p>\n<p>How do I make the test run without removing <code>TEXT</code> column type?</p>\n"
}, {
"tags" : [ "java", "swing", "inputverifier" ],
"owner" : {
"account_id" : 11415665,
"reputation" : 341,
"user_id" : 8368531,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/e0971307b6d3fa7d038cc2b998554fea?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Jörg",
"link" : "https://stackoverflow.com/users/8368531/j%c3%b6rg"
},
"is_answered" : true,
"view_count" : 54,
"answer_count" : 3,
"score" : 3,
"last_activity_date" : 1764926500,
"creation_date" : 1764890910,
"last_edit_date" : 1764922580,
"question_id" : 79838436,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838436/swing-tutorial-inputverifier-setup",
"title" : "Swing tutorial: InputVerifier setup",
"body" : "<p>Below you find the example code for an <a href=\"https://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/InputVerificationDialogDemoProject/src/misc/InputVerificationDialogDemo.java\" rel=\"nofollow noreferrer\">InputVerifier from the swing tutorial</a>, slightly modified to compile error-free under java 25.\nThe code creates an InputVerifer (<code>class MyVerifier</code>), which is set to the four JTextFields. Nowhere in the code the InputVerifier is "removed" (set to null), but in its <code>shouldYieldFocus(...)</code> method it is set anew with every verification (<code>input.setInputVerifier(this)</code>). Commenting out this line shows no different behaviour on my side. So is this line at least recommendable or maybe even necessary for reasons I cannot figure out?</p>\n<pre><code>//package misc;\n \nimport java.util.Set;\nimport java.util.HashSet;\n \nimport java.awt.*;\nimport java.awt.event.*;\n \nimport javax.swing.*;\nimport javax.swing.event.*;\nimport javax.swing.text.*;\n \nimport java.beans.PropertyChangeListener;\nimport java.beans.PropertyChangeEvent;\n \nimport java.text.*;\n \n/**\n * InputVerificationDialogDemo.java is a 1.4 example that\n * requires no other files.\n *\n * Yet another mortgage calculator.\n * However, instead of using a formatted text field,\n * as shown in FormattedTextFieldDemo, this example\n * uses input verification to validate user input.\n * This one uses a dialog to warn people when their input is bad.\n */\npublic class InputVerificationDialogDemo extends JPanel {\n //Default values\n private static double DEFAULT_AMOUNT = 100000;\n private static double DEFAULT_RATE = 7.5; //7.5 %\n private static int DEFAULT_PERIOD = 30;\n \n //Labels to identify the text fields\n private JLabel amountLabel;\n private JLabel rateLabel;\n private JLabel numPeriodsLabel;\n private JLabel paymentLabel;\n \n //Strings for the labels\n private static String amountString = "Loan Amount (10,000 - 10,000,000): ";\n private static String rateString = "APR (>= 0%): ";\n private static String numPeriodsString = "Years (1-40): ";\n private static String paymentString = "Monthly Payment: ";\n \n //Text fields for data entry\n private JTextField amountField;\n private JTextField rateField;\n private JTextField numPeriodsField;\n private JTextField paymentField;\n \n //Formats to format and parse numbers\n private NumberFormat moneyFormat;\n private NumberFormat percentFormat;\n private DecimalFormat decimalFormat;\n private DecimalFormat paymentFormat;\n private NumberFormat integerFormat;\n private MyVerifier verifier = new MyVerifier();\n \n public InputVerificationDialogDemo() {\n super(new BorderLayout());\n setUpFormats();\n double payment = computePayment(DEFAULT_AMOUNT,\n DEFAULT_RATE,\n DEFAULT_PERIOD);\n \n //Create the labels.\n amountLabel = new JLabel(amountString);\n rateLabel = new JLabel(rateString);\n numPeriodsLabel = new JLabel(numPeriodsString);\n paymentLabel = new JLabel(paymentString);\n \n //Create the text fields and set them up.\n amountField = new JTextField(moneyFormat.format(DEFAULT_AMOUNT), 10);\n amountField.setInputVerifier(verifier);\n \n rateField = new JTextField(percentFormat.format(DEFAULT_RATE), 10);\n rateField.setInputVerifier(verifier);\n \n numPeriodsField = new JTextField(decimalFormat.format(DEFAULT_PERIOD), 10);\n numPeriodsField.setInputVerifier(verifier);\n \n paymentField = new JTextField(paymentFormat.format(payment), 10);\n paymentField.setInputVerifier(verifier);\n paymentField.setEditable(false);\n //Remove this component from the focus cycle.\n paymentField.setFocusable(false); \n paymentField.setForeground(Color.red);\n \n //Register an action listener to handle Return.\n amountField.addActionListener(verifier);\n rateField.addActionListener(verifier);\n numPeriodsField.addActionListener(verifier);\n \n //Tell accessibility tools about label/textfield pairs.\n amountLabel.setLabelFor(amountField);\n rateLabel.setLabelFor(rateField);\n numPeriodsLabel.setLabelFor(numPeriodsField);\n paymentLabel.setLabelFor(paymentField);\n \n //Lay out the labels in a panel.\n JPanel labelPane = new JPanel(new GridLayout(0,1));\n labelPane.add(amountLabel);\n labelPane.add(rateLabel);\n labelPane.add(numPeriodsLabel);\n labelPane.add(paymentLabel);\n \n //Layout the text fields in a panel.\n JPanel fieldPane = new JPanel(new GridLayout(0,1));\n fieldPane.add(amountField);\n fieldPane.add(rateField);\n fieldPane.add(numPeriodsField);\n fieldPane.add(paymentField);\n \n //Put the panels in this panel, labels on left,\n //text fields on right.\n setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));\n add(labelPane, BorderLayout.CENTER);\n add(fieldPane, BorderLayout.LINE_END);\n }\n \n class MyVerifier extends InputVerifier \n implements ActionListener {\n double MIN_AMOUNT = 10000.0;\n double MAX_AMOUNT = 10000000.0;\n double MIN_RATE = 0.0;\n int MIN_PERIOD = 1;\n int MAX_PERIOD = 40;\n String message = null;\n \n public boolean shouldYieldFocus(JComponent input, JComponent target) {\n boolean inputOK = verify(input);\n makeItPretty(input);\n updatePayment();\n \n if (inputOK) {\n return true;\n }\n \n \n //Beep and then tell whoever called us that we don't\n //want to yield focus.\n Toolkit.getDefaultToolkit().beep();\n //Pop up the message dialog.\n message += ".\\nPlease try again.";\n JOptionPane.showMessageDialog(null, //no owner frame\n message, //text to display\n "Invalid Value", //title\n JOptionPane.WARNING_MESSAGE);\n// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n //Reinstall the input verifier. - - WHY??\n// input.setInputVerifier(this);\n// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n \n/* Following lines moved up, to beep with the error message, not after closing the OptionPane.\n //Beep and then tell whoever called us that we don't\n //want to yield focus.\n Toolkit.getDefaultToolkit().beep();\n*/\n return false;\n }\n \n protected void updatePayment() {\n double amount = DEFAULT_AMOUNT;\n double rate = DEFAULT_RATE;\n int numPeriods = DEFAULT_PERIOD;\n double payment = 0.0;\n \n //Parse the values.\n try {\n amount = moneyFormat.parse(amountField.getText()).\n doubleValue();\n } catch (ParseException pe) {}\n try {\n rate = percentFormat.parse(rateField.getText()).\n doubleValue();\n } catch (ParseException pe) {}\n try {\n numPeriods = decimalFormat.parse(numPeriodsField.getText()).\n intValue();\n } catch (ParseException pe) {}\n \n //Calculate the result and update the GUI.\n payment = computePayment(amount, rate, numPeriods);\n paymentField.setText(paymentFormat.format(payment));\n }\n \n //This method checks input, but should cause no side effects.\n public boolean verify(JComponent input) {\n return checkField(input, false);\n }\n \n protected void makeItPretty(JComponent input) {\n checkField(input, true);\n }\n \n protected boolean checkField(JComponent input, boolean changeIt) {\n if (input == amountField) {\n return checkAmountField(changeIt);\n } else if (input == rateField) {\n return checkRateField(changeIt);\n } else if (input == numPeriodsField) {\n return checkNumPeriodsField(changeIt);\n } else {\n return true; //shouldn't happen\n }\n }\n \n //Checks that the amount field is valid. If it is valid,\n //it returns true, otherwise it sets the message field and\n //returns false. If the change argument is true, set\n //the textfield to the parsed number so that it looks\n //good -- no letters, for example.\n public boolean checkAmountField(boolean change) {\n boolean wasValid = true;\n double amount = DEFAULT_AMOUNT;\n \n //Parse the value.\n try {\n amount = moneyFormat.parse(amountField.getText()).\n doubleValue();\n } catch (ParseException pe) {\n message = "Invalid money format in Loan Amount field";\n return false;\n }\n \n //Value was invalid.\n if ((amount < MIN_AMOUNT) || (amount > MAX_AMOUNT)) {\n wasValid = false;\n if (amount < MIN_AMOUNT) {\n message = "Loan Amount was < "\n + integerFormat.format(MIN_AMOUNT);\n } else { //amount is greater than MAX_AMOUNT\n message = "Loan Amount was > "\n + integerFormat.format(MAX_AMOUNT);\n }\n }\n \n //Whether value was valid or not, format it nicely.\n if (change) {\n amountField.setText(moneyFormat.format(amount));\n amountField.selectAll();\n }\n return wasValid;\n }\n \n //Checks that the rate field is valid. If it is valid,\n //it returns true, otherwise it sets the message field and\n //returns false. If the change argument is true, set the\n //textfield to the parsed number so that it looks good -- no \n //letters, for example.\n public boolean checkRateField(boolean change) {\n boolean wasValid = true;\n double rate = DEFAULT_RATE;\n \n //Parse the value.\n try {\n rate = percentFormat.parse(rateField.getText()).\n doubleValue();\n } catch (ParseException pe) {\n message = "Invalid percent format in APR field";\n return false;\n }\n \n //Value was invalid.\n if (rate < MIN_RATE) {\n wasValid = false;\n message = "Bad value: APR was < " + MIN_RATE;\n }\n \n //Whether value was valid or not, format it nicely.\n if (change) {\n rateField.setText(percentFormat.format(rate));\n rateField.selectAll();\n }\n \n return wasValid;\n }\n \n //Checks that the numPeriods field is valid. If it is valid,\n //it returns true, otherwise it sets the message field and\n //returns false. If the change argument is true, set the \n //textfield to the parsed number so that it looks good -- no\n //letters, for example.\n public boolean checkNumPeriodsField(boolean change) {\n boolean wasValid = true;\n int numPeriods = DEFAULT_PERIOD;\n \n //Parse the value.\n try {\n numPeriods = decimalFormat.parse(numPeriodsField.getText()).\n intValue();\n } catch (ParseException pe) {\n message = "Invalid decimal format in Years field";\n return false;\n }\n \n //Value was invalid.\n if (numPeriods < MIN_PERIOD) {\n wasValid = false;\n message = "Bad value: Number of years was < "\n + integerFormat.format(MIN_PERIOD);\n } else if (numPeriods > MAX_PERIOD) {\n wasValid = false;\n message = "Bad value: Number of years was > "\n + integerFormat.format(MAX_PERIOD);\n }\n \n //Whether value was valid or not, format it nicely.\n if (change) {\n numPeriodsField.setText(decimalFormat.format(numPeriods));\n numPeriodsField.selectAll();\n }\n \n return wasValid;\n }\n \n public void actionPerformed(ActionEvent e) {\n JTextField source = (JTextField)e.getSource();\n shouldYieldFocus(source); //ignore return value\n source.selectAll();\n }\n }\n \n /**\n * Create the GUI and show it. For thread safety,\n * this method should be invoked from the\n * event-dispatching thread.\n */\n private static void createAndShowGUI() {\n //Create and set up the window.\n JFrame frame = new JFrame("InputVerificationDialogDemo");\n frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n JComponent newContentPane = new InputVerificationDialogDemo();\n newContentPane.setOpaque(true); //content panes must be opaque\n frame.setContentPane(newContentPane);\n \n //Display the window.\n frame.pack();\n frame.setVisible(true);\n }\n \n public static void main(String[] args) {\n /* Use an appropriate Look and Feel */\n try {\n //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");\n //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");\n UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");\n } catch (UnsupportedLookAndFeelException ex) {\n ex.printStackTrace();\n } catch (IllegalAccessException ex) {\n ex.printStackTrace();\n } catch (InstantiationException ex) {\n ex.printStackTrace();\n } catch (ClassNotFoundException ex) {\n ex.printStackTrace();\n }\n /* Turn off metal's use of bold fonts */\n UIManager.put("swing.boldMetal", Boolean.FALSE);\n \n //Schedule a job for the event-dispatching thread:\n //creating and showing this application's GUI.\n javax.swing.SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n createAndShowGUI();\n }\n });\n }\n \n //Compute the monthly payment based on the loan amount,\n //APR, and length of loan.\n double computePayment(double loanAmt, double rate, int numPeriods) {\n double I, partial1, denominator, answer;\n \n numPeriods *= 12; //get number of months\n if (rate > 0.01) { \n I = rate / 100.0 / 12.0; //get monthly rate from annual\n partial1 = Math.pow((1 + I), (0.0 - numPeriods));\n denominator = (1 - partial1) / I;\n } else { //rate ~= 0\n denominator = numPeriods;\n }\n answer = (-1 * loanAmt) / denominator;\n return answer;\n }\n \n //Create and set up number formats. These objects also\n //parse numbers input by user.\n private void setUpFormats() {\n moneyFormat = (NumberFormat)NumberFormat.getNumberInstance();\n \n percentFormat = NumberFormat.getNumberInstance();\n percentFormat.setMinimumFractionDigits(3);\n \n decimalFormat = (DecimalFormat)NumberFormat.getNumberInstance();\n decimalFormat.setParseIntegerOnly(true);\n \n paymentFormat = (DecimalFormat)NumberFormat.getNumberInstance();\n paymentFormat.setMaximumFractionDigits(2);\n paymentFormat.setNegativePrefix("(");\n paymentFormat.setNegativeSuffix(")");\n \n integerFormat = NumberFormat.getIntegerInstance();\n }\n}\n</code></pre>\n"
}, {
"tags" : [ "java", "javafx", "module-path" ],
"owner" : {
"account_id" : 29286250,
"reputation" : 11,
"user_id" : 22437743,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a/AAcHTtfl9nDlu6Hqqb9r8JpaNuAk5bH8W5nXgP3sUmazo2z4ag=k-s256",
"display_name" : "France Miguel Jaen",
"link" : "https://stackoverflow.com/users/22437743/france-miguel-jaen"
},
"is_answered" : false,
"view_count" : 49,
"answer_count" : 0,
"score" : 1,
"last_activity_date" : 1764998780,
"creation_date" : 1764884430,
"last_edit_date" : 1764998780,
"question_id" : 79838375,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838375/javafx-controls-module-cant-be-found-but-its-exists-in-the-right-location",
"title" : "javafx.controls module can't be found but its exists in the right location",
"body" : "<p>I using <strong>JDK 25</strong> and <strong>Apache Netbeans</strong> and <strong>Windows 11</strong>. My JavaFX SDK folder is in <code>C:\\</code> and I verified that it is indeed in the <em>lib</em> folder, but the compiler still says it can't find it. I'm pretty sure I initialized the correct VM options. Oh, and my <strong>build tool is Ant</strong>.</p>\n<p>VM Options:</p>\n<pre class=\"lang-none prettyprint-override\"><code>--module-path "C:\\javafx-sdk-25.0.1\\lib" --add-modules=javafx.controls,javafx.fxml\n</code></pre>\n<p>Erorr Message I keep getting:</p>\n<blockquote>\n<p>Error occurred during initialization of boot layer<br />\njava.lang.module.FindException: Module javafx.fxml not found</p>\n</blockquote>\n<p>Also can't find <code>javafx.controls</code></p>\n<p>Question: What am I possibly doing wrong and why can't the compiler find these two files?</p>\n<p>I read some stuff regarding dependencies causing this type of error. If that is the case can someone explain on how I would be able to configure these <em>dependencies</em> properly?</p>\n<p>Full Code (if it helps):</p>\n<pre class=\"lang-java prettyprint-override\"><code>/*\n * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license\n * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template\n */\npackage robot2;\n\n// Java FX library for playing mp3 audios\n\nimport com.phidget22.*;\nimport javafx.application.Application;\nimport javafx.scene.Scene;\n//import javafx.scene.control.Label;\nimport javafx.stage.Stage;\nimport javafx.scene.media.*;\nimport java.io.FileInputStream;\nimport static javafx.application.Application.launch;\n/**\n *\n * @author #\n */\npublic class Robot2 extends Application {\n \n private boolean alarmBlaring = false; // debounce boolean. prevents multiple JavaFX threads while one is already active\n \n /**\n * @param args the command line arguments\n */\n @Override\n public void start (Stage stage)\n {\n if (!alarmBlaring)\n {\n alarmBlaring = true;\n System.out.println("Alarm playing!");\n String fileDir = "\\"C:\\\\Users\\\\#\\\\Downloads\\\\alarm-clock-90867.mp3\\""; // path to the mp3 audio file of the alarm\n Media audioMedia = new Media(fileDir); // gets the file from the directory string\n MediaPlayer alarm = new MediaPlayer(audioMedia); // declares the player of the mp3 file\n alarm.setVolume(0.5);\n alarm.setCycleCount(MediaPlayer.INDEFINITE); // loops the alarm audio indefinitely\n try\n {\n alarm.play();\n Thread.sleep(10000); // stop the alarm audio after 10 seconds\n alarm.stop();\n alarmBlaring = false;\n }\n catch (Exception e)\n {\n alarmBlaring = false;\n System.out.println("error occured: " + e); // print out error message\n }\n }\n }\n \n public static void main(String[] args) throws Exception{\n // TODO code application logic here\n \n // configs\n float dbThreshold = 20f; // the max difference to trigger the output device (speaker/light)\n \n // inits\n FileInputStream alarmDir = new FileInputStream(".mp3");\n \n SoundSensor dbChecker = new SoundSensor();\n double prevDb = 0;\n \n dbChecker.setHubPort(4);\n //dbChecker.setIsHubPortDevice(true);\n \n //greenLED.open(1000);\n dbChecker.open(5000);\n \n while (true)\n {\n try\n {\n double db = dbChecker.getdB();\n if (prevDb == 0)\n {\n prevDb = db;\n } else\n {\n System.out.println("db: " + db + " | " + "prev: " + prevDb);\n double dbDiff = db - prevDb;\n if (dbDiff > dbThreshold)\n {\n launch(args);\n } \n }\n prevDb = db;\n \n //System.out.println("Recorded Decibles: " + db);\n // db spike logic\n }\n catch (PhidgetException err)\n {\n System.out.println("Decibles exceed sensor capability");\n }\n Thread.sleep(250);\n }\n }\n}\n</code></pre>\n"
}, {
"tags" : [ "java", "string", "http", "http-headers", "text-parsing" ],
"owner" : {
"account_id" : 22114836,
"reputation" : 1,
"user_id" : 16369121,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/f3809bc9ffd8edb176ab83509e08e0c2?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Abdelouahab ",
"link" : "https://stackoverflow.com/users/16369121/abdelouahab"
},
"is_answered" : true,
"view_count" : 49,
"answer_count" : 2,
"score" : 0,
"last_activity_date" : 1764885099,
"creation_date" : 1764878538,
"last_edit_date" : 1764879847,
"question_id" : 79838312,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838312/how-to-handle-variable-length-header-values-when-parsing-http-requests-in-java",
"title" : "How to handle variable-length header values when parsing HTTP requests in Java?",
"body" : "<p>I'm building an HTTP server and parsing request headers. My current code fails when the <code>Host</code> header includes a port number because I'm splitting on <code>:</code>.</p>\n<p><strong>Current Code:</strong></p>\n<pre class=\"lang-java prettyprint-override\"><code>String[] header = line.split(":");\nString key = header[0].trim();\nString value = header[1].trim();\nif (key.equals("Host")) {\n value = value + ":" + header[2]; // ArrayIndexOutOfBoundsException!\n}\n</code></pre>\n<p><strong>Problem:</strong></p>\n<ul>\n<li><p>Works for <code>Host: example.com:8080</code></p>\n</li>\n<li><p>Fails for <code>Host: example.com</code> (no port)</p>\n</li>\n</ul>\n<p><strong>Question:</strong></p>\n<p>What's the best way to rejoin header values that may contain colons?</p>\n<p><strong>What I've tried:</strong></p>\n<ul>\n<li><p>Checking <code>header.length</code> but feels clunky</p>\n</li>\n<li><p>Using <code>indexOf(':')</code> instead of <code>split()</code></p>\n</li>\n</ul>\n<p>Which approach is more robust for HTTP header parsing?</p>\n"
}, {
"tags" : [ "java", "shader", "processing", "fragment-shader" ],
"owner" : {
"account_id" : 23865169,
"reputation" : 3,
"user_id" : 17867596,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/0300fee018dd129352f17a10e5ed1acf?s=256&d=identicon&r=PG",
"display_name" : "helpthisnoob",
"link" : "https://stackoverflow.com/users/17867596/helpthisnoob"
},
"is_answered" : false,
"view_count" : 50,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764868688,
"creation_date" : 1764868688,
"question_id" : 79838187,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838187/how-to-prevent-pixels-from-overwriting-each-other-in-processing",
"title" : "How to prevent pixels from overwriting each other in processing?",
"body" : "<p>I am learning dithering, and the best way for me to do this is to play around in processing. My end goal is to create something that mimics the aesthetic of <em>The Return of Obra Dinn.</em></p>\n<p>My code so far does 2 things:</p>\n<ol>\n<li>detect edges and change the color of edge pixels to white</li>\n<li>complete bayer dithering (though i think I may have done it a little differently than true bayer dithering. but this is not my issue, i'm fine the way it is and learning this on my own).</li>\n</ol>\n<p>The issue I am having is that the white edge pixels are not rendering. If I remove all the bayer dithering pieces in the draw function, it does draw correctly. However, with the bayer dithering it disappears. I sense it has to do with the order of how I'm rendering this, but I can't seem to figure out what I should change.</p>\n<p>So far, I have tried moving things around in the draw function so that the whole chunk of changing edges happens at the end of the draw function rather than the start. I've also tried adding an if statement so that any white pixels on img are skipped when going through the loops of dithering. Maybe I'm loading and updating pixels incorrectly?</p>\n<pre><code>PImage img;\ncolor white= color(255);\ncolor black=color(0);\nIntList seed;\nint starter=0;\nint z=0;\nint v= 0;\nint gCols=0;\nint gRows=0;\nint [][]gMatrix;\ncolor light= #e5ffff;\ncolor dark= #333319;\nfloat pRound= 0;\nfloat gRound=0;\n\nvoid setup (){\n size (800,500);\n img= loadImage("nosferatu.jpg");\n noLoop();\n img.loadPixels();\n seed= new IntList(0,32,8,40,2,34,10,42,48,16,56,24,50,18,58,26,12,44,4,36,14,46,6,38,60,28,52,20,62,30,54,22,3,35,11,43,1,33,9,41,51,19,59,27,49,17,57,25,15,47,7,39,13,45,5,37,63,31,55,23,61,29,53,21);\n for (int k=0; k<seed.size();k++){\n int newK= seed.get(k);\n int newS= (newK/63)*255;\n seed.set(k,newS);\n }\n int cols= 8;\n int rows= 8;\n int [][]matrix= new int [cols][rows];\n for (int i = 0; i <rows; i++){\n for (int j = 0; j<cols; j++){\n matrix[j][i]= seed.get(starter);\n starter=starter+1;\n }\n }\n int fCols= img.width;\n int fRows= img.height;\n int [][]fMatrix = new int [fCols][fRows];\n for (int t=0; t<fRows; t++){\n if (v>7){\n v=0;\n }\n for (int s=0; s<fCols; s++){\n if (z>7){\n z=0;\n }\n fMatrix[s][t]= matrix[z][v];\n z=z+1;\n }\n v=v+1;\n \n}\n gCols= img.width;\n gRows= img.height;\n gMatrix= new int [gCols][gRows];\n for (int q=0; q<gRows; q++){\n for (int p=0; p<gCols; p++){\n gMatrix[p][q]= fMatrix[p][q];\n }\n \n}\n}\n\nvoid draw () {\n image(img,0,0);\n img.filter(GRAY);\n img.loadPixels();\n PImage grayImg = img.copy();\n grayImg.filter (BLUR,13);\n grayImg.loadPixels();\n for (int y=1; y<grayImg.height-1; y++) {\n for (int x=1; x<grayImg.width-1; x++){\n color gValue= grayImg.get (x,y);\n float g2Value= red(gValue);\n color lValue= grayImg.get(x-1,y);\n float l2Value= red(lValue);\n color rValue= grayImg.get(x+1,y);\n float r2Value= red(rValue);\n color bValue= grayImg.get(x, y+1);\n float b2Value= red(bValue);\n float rSub= abs(g2Value-r2Value);\n float lSub=abs(g2Value-l2Value);\n float bSub= abs(g2Value-b2Value);\n if ((rSub>5) || (lSub>5) || (bSub>5)){\n img.set(x,y,white);\n } \n \n }\n }\n for (int yy =0; yy<img.height; yy++){\n for (int xx=0; xx<img.width;xx++){\n color iValue= img.get(xx,yy);\n float pValue= red(iValue);\n if (pValue != white){\n if (pValue>255/2){\n pRound = 255;\n } else {\n pRound=0;\n } \n if (gMatrix[xx][yy]>255/2){\n gRound = 255;\n } else {\n gRound=0;\n } \n if (pValue>gMatrix[xx][yy]){\n if (pRound==255){\n img.set(xx,yy,light);\n } else {\n img.set(xx,yy,dark);\n }} else if (pValue < gMatrix[xx][yy]) {\n if (gRound == 255){\n img.set(xx,yy,light);\n } else {\n img.set(xx,yy,dark);\n }\n } else{\n img.set(xx,yy,gMatrix[xx][yy]);\n }\n }\n }\n }\n img.updatePixels();\n image(img,0,0);\n \n \n}\n</code></pre>\n<p>I know my code is not written efficiently. Again, I'm learning dithering so it's easier for me to first start by breaking up my challenge before optimizing.</p>\n<p>Looking for some help to figure out what I am doing wrong. Can you point me in the right direction at least?</p>\n"
}, {
"tags" : [ "java", "android", "android-studio", "smali" ],
"owner" : {
"account_id" : 34761195,
"reputation" : 1,
"user_id" : 26826325,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/2227e0c9079e7a0a0fd6eef1846cba80?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Ahn",
"link" : "https://stackoverflow.com/users/26826325/ahn"
},
"is_answered" : false,
"view_count" : 20,
"answer_count" : 0,
"score" : -1,
"last_activity_date" : 1764865400,
"creation_date" : 1764864641,
"last_edit_date" : 1764865400,
"question_id" : 79838128,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838128/android-studio-fail-to-load-plugin-descriptor-from-file-smalidea-zip",
"title" : "Android Studio - Fail to load plugin descriptor from file smalidea.zip",
"body" : "<p>I want to use smalidea plugin in Android Studio (version 4.1.1) from this github <a href=\"https://github.com/JesusFreke/smalidea\" rel=\"nofollow noreferrer\">repo</a> but after downloading many version of smalidea (.zip file) using their <a href=\"https://bitbucket.org/JesusFreke/smalidea/downloads\" rel=\"nofollow noreferrer\">DOWNLOAD LINK</a> and installed plugin from disk in Android Studio. AS returned the same error: "Fail to load plugin descriptor from file JesusFreke-smalidea-xxx.zip".</p>\n<p>I tried to use the some solution like changing version of Android Studio (3.5.1, 3.6.3) but it's not working.\nI also tried to</p>\n<ol>\n<li>Download smalidea-0.05.zip from bitbucket</li>\n<li>Extract the plugin.xml in smalidea/META-INF/ somewhere you can edit</li>\n<li>Add the following tag under the tag:\n< depends>com.intellij.modules.androidstudio</ depends></li>\n</ol>\n<p>Please help me to fix this, I appreciate any answer. <a href=\"https://i.sstatic.net/LKrTjZdr.png\" rel=\"nofollow noreferrer\">error in android studio</a></p>\n"
}, {
"tags" : [ "java", "regex", "unit-testing" ],
"owner" : {
"account_id" : 27523081,
"reputation" : 37,
"user_id" : 31391455,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/JfGXLng2.jpg?s=256",
"display_name" : "holysh",
"link" : "https://stackoverflow.com/users/31391455/holysh"
},
"is_answered" : true,
"view_count" : 72,
"answer_count" : 1,
"score" : -1,
"last_activity_date" : 1764952960,
"creation_date" : 1764863480,
"last_edit_date" : 1764952960,
"question_id" : 79838110,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79838110/how-can-i-solve-this-problem-of-test-difference",
"title" : "How can I solve this problem of test difference?",
"body" : "<p>As far as I understand, the difference between expected and actual one is <strong>NBSP</strong> (<a href=\"https://en.wikipedia.org/wiki/Non-breaking_space\" rel=\"nofollow noreferrer\">Non‐Breaking Space</a>).</p>\n<p>I don’t know how to remove this. It doesn’t get highlighted and cannot be found using CTRL+H (looking for \\u00A0).</p>\n<p><em>I've already tried:</em></p>\n<ul>\n<li>searching via CTRL+H to remove or replace it</li>\n<li>deleting the entire line and rewriting it manually.</li>\n</ul>\n<p><strong>here is the code of my test:</strong></p>\n<pre><code>void shouldReturnFullReport_whenGivenSeveralDrivers() {\n\n Map<String, RacerInfo> racers = new LinkedHashMap<>();\n racers.put("SVF", new RacerInfo("Sebastian Vettel", "FERRARI"));\n racers.put("DRR", new RacerInfo("Daniel Ricciardo", "RED BULL RACING TAG HEUER"));\n racers.put("VBM", new RacerInfo("Valtteri Bottas", "MERCEDES"));\n racers.put("LHM", new RacerInfo("Lewis Hamilton", "MERCEDES"));\n\n Map<String, Duration> lapTimes = new LinkedHashMap<>();\n lapTimes.put("SVF", Duration.ofMinutes(1).plusSeconds(4).plusMillis(415));\n lapTimes.put("DRR", Duration.ofMinutes(1).plusSeconds(12).plusMillis(13));\n lapTimes.put("VBM", Duration.ofMinutes(1).plusSeconds(12).plusMillis(434));\n lapTimes.put("LHM", Duration.ofMinutes(1).plusSeconds(12).plusMillis(460));\n\n String expected = """\n 1. Sebastian Vettel | FERRARI | 1:04.415\n 2. Daniel Ricciardo | RED BULL RACING TAG HEUER | 1:12.013\n 3. Valtteri Bottas | MERCEDES | 1:12.434\n 4. Lewis Hamilton | MERCEDES | 1:12.460\n """;\n\n assertEquals(expected, ResultFormatter.format(lapTimes, racers));\n}\n</code></pre>\n<p><a href=\"https://i.sstatic.net/Tg95nmJj.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.sstatic.net/Tg95nmJj.png\" alt=\"here is the difference between expected and actual one\" /></a></p>\n"
}, {
"tags" : [ "java", "spring", "spring-boot", "mcp-server" ],
"owner" : {
"account_id" : 44524247,
"reputation" : 11,
"user_id" : 31797545,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/ebc59fb36d33cafa2920c72faa04e6fe?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "user31797545",
"link" : "https://stackoverflow.com/users/31797545/user31797545"
},
"is_answered" : false,
"view_count" : 36,
"answer_count" : 0,
"score" : 1,
"last_activity_date" : 1764856907,
"creation_date" : 1764856279,
"last_edit_date" : 1764856907,
"question_id" : 79837982,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79837982/how-to-connect-to-mcp-server-transport-type-streamable-http-in-mcp-inspector",
"title" : "How to connect to MCP server (Transport type: Streamable HTTP) in MCP Inspector (v0.17.2)",
"body" : "<p>I have this local MCP-server and I want to test with this <a href=\"https://modelcontextprotocol.io/docs/tools/inspector\" rel=\"nofollow noreferrer\">MCP Inspector</a>, I followed this <a href=\"https://medium.com/@laurentkubaski/how-to-use-mcp-inspector-2748cd33faeb\" rel=\"nofollow noreferrer\">tutorial</a> but it does not work.</p>\n<p><a href=\"https://i.sstatic.net/6HNuvMwB.png\" rel=\"nofollow noreferrer\">Got this following error.</a></p>\n<p>My MCP-server written in java (Spring boot) using:</p>\n<pre><code><dependency> \n <groupId>org.springframework.ai</groupId> \n <artifactId>spring-ai-starter-mcp-server-webflux</artifactId> \n</dependency>\n</code></pre>\n<p>McpApplication.java</p>\n<pre><code>@SpringBootApplication \npublic class McpApplication { \n \n public static void main(String args) { \n SpringApplication.run(McpApplication.class, args); \n } \n \n @Bean \n public ToolCallbackProvider employeeTools(EmployeeService employeeService) { \n return MethodToolCallbackProvider.builder().toolObjects(employeeService).build(); \n } \n} \n</code></pre>\n<p>ToolService.java</p>\n<pre><code>@Service \n@RequiredArgsConstructor \n@Slf4j \npublic class EmployeeService { \n \nprivate final SomeRepository someRepository; \n \n@Tool(description ="Tool Description") \npublic Flux<ResponseChunk> toolMethod( Param param) { \n // Tool implementation here. \n} \n} \n</code></pre>\n<p>And these are config option.</p>\n<pre><code>\nspring.ai.mcp.server.enabled=true spring.ai.mcp.server.name=filter-mcp-server spring.ai.mcp.server.version=0.0.1 spring.ai.mcp.server.protocol=STREAMABLE spring.ai.mcp.server.type=ASYNC spring.ai.mcp.server.endpoint=/mcp spring.ai.mcp.server.stdio=false\n</code></pre>\n<p>Need some help!</p>\n"
}, {
"tags" : [ "java", "javafx" ],
"owner" : {
"account_id" : 10187542,
"reputation" : 2677,
"user_id" : 20692967,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/NZSXm.jpg?s=256",
"display_name" : "Sergey Zolotarev",
"link" : "https://stackoverflow.com/users/20692967/sergey-zolotarev"
},
"is_answered" : true,
"view_count" : 94,
"answer_count" : 7,
"score" : 1,
"last_activity_date" : 1764859131,
"creation_date" : 1764842953,
"question_id" : 79837783,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79837783/disable-button-as-click-is-still-processed",
"title" : "Disable Button as click is still processed",
"body" : "<p>Suppose a click on a JavaFX button is processed for some period of time (e.g. it performs some IO). How do you block interaction with that button while a click is still being processed? Say, it is processed for one second, and during that second no clicks made by the user should be processed.</p>\n<p>I feel there's a better way than to manually manipulate the <code>disable</code> property.</p>\n<p>Java 8, JavaFX 8.</p>\n<pre class=\"lang-java prettyprint-override\"><code> private Button createOkButton() {\n Button ok = new Button("OK");\n ok.setOnAction(e -> onOk());\n }\n\n private void onOk() {\n ok.setDisable(true);\n doSomething();\n ok.setDisable(false);\n }\n</code></pre>\n"
}, {
"tags" : [ "java" ],
"owner" : {
"account_id" : 30705601,
"reputation" : 1,
"user_id" : 23543144,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/miGxH.png?s=256",
"display_name" : "ablyworks",
"link" : "https://stackoverflow.com/users/23543144/ablyworks"
},
"is_answered" : false,
"view_count" : 46,
"closed_date" : 1764842878,
"answer_count" : 0,
"score" : -5,
"last_activity_date" : 1764839064,
"creation_date" : 1764838065,
"last_edit_date" : 1764839064,
"question_id" : 79837707,
"link" : "https://stackoverflow.com/questions/79837707/issue-integrating-aeps-api-with-java-backend",
"closed_reason" : "Not suitable for this site",
"title" : "Issue Integrating AEPS API With Java Backend",
"body" : "<p>I am building an AEPS service panel in <strong>Java + React</strong>.<br />\nWhile integrating an AEPS API, I am facing an issue where the request takes too long and returns a timeout.</p>\n<h3><strong>My backend setup:</strong></h3>\n<ul>\n<li><p>Java (Spring Boot)</p>\n</li>\n<li><p>React frontend</p>\n</li>\n<li><p>Using external AEPS API for cash withdrawal & balance check</p>\n</li>\n<li><p>Server deployed on a VPS</p>\n</li>\n</ul>\n<h3><strong>My Problem:</strong></h3>\n<p>Whenever I send a request to the AEPS API endpoint, I get:</p>\n<h3><strong>Code Snippet:</strong></h3>\n<h3><strong>What I Have Tried:</strong></h3>\n<ul>\n<li><p>Increasing timeout</p>\n</li>\n<li><p>Changing internet network</p>\n</li>\n<li><p>Testing API via Postman (works fine)</p>\n</li>\n<li><p>Tried adding connection timeout:</p>\n</li>\n</ul>\n<p>Still getting timeout only from Java backend, not Postman.</p>\n<h3><strong>Expected Output:</strong></h3>\n<p>API response (JSON) with transaction status.</p>\n<h3><strong>Actual Output:</strong></h3>\n<p>Timeout exception only from Java code.</p>\n"
}, {
"tags" : [ "java", "swing", "jcombobox" ],
"owner" : {
"account_id" : 42475837,
"reputation" : 1,
"user_id" : 30771329,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/64d14c2de34be10714ed989913167cef?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Sam Shipley",
"link" : "https://stackoverflow.com/users/30771329/sam-shipley"
},
"is_answered" : true,
"view_count" : 54,
"answer_count" : 1,
"score" : -3,
"last_activity_date" : 1764856813,
"creation_date" : 1764827083,
"question_id" : 79837547,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79837547/java-swing-jcombobox-getselecteditem-not-finding-the-object-cannot-be-resol",
"title" : "Java Swing - JComboBox getSelectedItem() not finding the object (cannot be resolved)",
"body" : "<p>I'm making a simple budget calculator tool, where I have a couple input boxes, and a <code>JComboBox</code> to select /week, /month, or /year</p>\n<p>I assumed I could just call <code>getSelectedItem()</code> on <em>foodRateBox</em> to get the selected item like I can with getting the text from a field such as <em>foodField</em> using <code>getText()</code>, but when I try it, I get:</p>\n<blockquote>\n<p>"foodRateBox cannot be resolved <em>Java(570425394)</em>"</p>\n</blockquote>\n<p>What am I missing?</p>\n<p>Basic stuff:</p>\n<pre class=\"lang-java prettyprint-override\"><code>public class BudgetBase extends JPanel { // based on Swing JPanel\n\n JFrame topLevelFrame; // top-level JFrame\n GridBagConstraints layoutConstraints = new GridBagConstraints(); // layout\n\n private JButton calculateButton; // Calculate button\n private JButton exitButton; // Exit button\n\n private JTextField wagesField; // Wages text field\n private JTextField loansField; // Loans text field\n private JTextField otherIncomeField; // text field for anyhting else\n private JTextField totalIncomeField; // Total Income field\n\n private JTextField foodField; // food text field\n private JTextField rentField; // rent text field\n private JTextField otherSpendingField; // text field for anyhting else\n private JTextField totalSpendingField; // Total Spending field\n\n private JTextField deficitField; // difference between spending and income\n String[] rate = {"/week", "/month", "/year"}; // selection for the JComboBoxes\n...\n</code></pre>\n<p>Then I have a function for the components and adding them to the gridbag</p>\n<pre class=\"lang-java prettyprint-override\"><code>private void initComponents() { \n\n ...\n\n// Row 1 - Wages label, box, and text field\n JLabel wagesLabel = new JLabel("Wages");\n addComponent(wagesLabel, 1, 0);\n\n final JComboBox<String> wagesRateBox = new JComboBox<String>(rate);\n addComponent(wagesRateBox, 1, 1);\n\n wagesField = new JTextField("", 10); // blank initially, with 10 columns\n wagesField.setHorizontalAlignment(JTextField.RIGHT) ; \n addComponent(wagesField, 1, 2); \n\n ...\n</code></pre>\n<p>When the <em>calculate</em> button is pressed, it calls a function to do some calculations and this is where I want to get the item in the <code>JComboBox</code>.</p>\n<pre class=\"lang-java prettyprint-override\"><code>public double calculateTotalSpending() {\n\n // get values from spendng text fields. valie is NaN if an error occurs\n String spendingError = ""; // track errors to output as one message\n double food = getTextFieldValue(foodField);\n double rent = getTextFieldValue(rentField);\n double otherS = getTextFieldValue(otherSpendingField); //otherS for 'Other Spending'\n\n String foodRate = foodRateBox.getSelectedItem();\n\n ...\n</code></pre>\n<p><code>getTextFieldValue</code> is just this:</p>\n<pre class=\"lang-java prettyprint-override\"><code>private double getTextFieldValue(JTextField field) {\n\n // get value as String from field\n String fieldString = field.getText(); // get text from text field\n\n if ((fieldString.trim()).equals("")) { // if text field is blank, return 0\n return 0.0;\n } \n\n else { // if text field is not blank, parse it into a double\n try {\n return Double.parseDouble(fieldString); // parse field number into a double\n } catch (java.lang.NumberFormatException ex) { // catch invalid number exception\n return Double.NaN; // return NaN to show that field is not a number\n }\n }\n}\n</code></pre>\n"
}, {
"tags" : [ "java", "solr", "ddf" ],
"owner" : {
"account_id" : 965027,
"reputation" : 31,
"user_id" : 988606,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/53cb63d60b9760bb0af8d42647fb0491?s=256&d=identicon&r=PG",
"display_name" : "webBuilder",
"link" : "https://stackoverflow.com/users/988606/webbuilder"
},
"is_answered" : false,
"view_count" : 29,
"answer_count" : 0,
"score" : 1,
"last_activity_date" : 1764812821,
"creation_date" : 1764812821,
"question_id" : 79837459,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79837459/unable-to-ingest-geojson-into-ddf-2-26-45-solr-error-ingest-fails-with-no-det",
"title" : "Unable to ingest GeoJSON into DDF 2.26.45 (Solr error + ingest fails with no detailed message)",
"body" : "<p>I'm running DDF 2.26.45 on macOS and configured it to use an external Solr 8.6.1 running locally at:</p>\n<pre><code>http://localhost:8983/solr\n</code></pre>\n<p>DDF detects Solr correctly:</p>\n<pre><code>solr.client = HttpSolrClient\nsolr.http.url = http://localhost:8983/solr\n</code></pre>\n<p>I created a Solr core:</p>\n<pre><code>./solr create -c alerts -s 1 -rf 1\n</code></pre>\n<p>Solr starts correctly.</p>\n<hr />\n<h2>Goal</h2>\n<p>I want to ingest a simple GeoJSON file into the DDF catalog.</p>\n<p>File: /tmp/test-location.geojson</p>\n<pre><code>{\n "type": "FeatureCollection",\n "features": [\n {\n "type": "Feature",\n "geometry": {\n "type": "Point",\n "coordinates": [-77.0369, 38.9072]\n },\n "properties": {\n "name": "Test Location"\n }\n }\n ]\n}\n</code></pre>\n<hr />\n<h2>Command used inside DDF Karaf</h2>\n<pre><code>catalog:ingest -t geojson /tmp/test-location.geojson\n</code></pre>\n<p>Also tried:</p>\n<pre><code>catalog:ingest -t geojson -s catalog /tmp/test-location.geojson\n</code></pre>\n<hr />\n<h2>Result</h2>\n<pre><code>0 file(s) ingested in 0 seconds\n1 file(s) failed to be ingested. See the ingest log for more details.\n</code></pre>\n<p>Enabled debug logging:</p>\n<pre><code>log:set DEBUG org.codice.ddf.commands.catalog.IngestCommand\n</code></pre>\n<hr />\n<h2>ingest_error.log excerpts</h2>\n<pre><code>2025-12-03T13:28:26,449 | INFO | location.geojson | ingestLogger | f.commands.catalog.IngestCommand 338 | 455 - catalog-core-commands - 2.26.45 | 0 file(s) ingested in 0 seconds [0 records/sec]\n2025-12-03T13:28:26,449 | WARN | location.geojson | ingestLogger | f.commands.catalog.IngestCommand 351 | 455 - catalog-core-commands - 2.26.45 | 1 file(s) failed to be ingested.\n(repeats every attempt)\n</code></pre>\n<hr />\n<h2>ddf.log Solr error spam</h2>\n<pre><code>Error retrieving system alert.\norg.codice.ddf.persistence.PersistenceException\n\nCaused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:\nError from server at http://localhost:8983/solr/alerts:\ncan not sort on multivalued field: id_txt of type: text_general\n</code></pre>\n<hr />\n<h2>Additional details</h2>\n<p>GeoJSON transformers appear in service:list:</p>\n<pre><code>id = catalog.data.metacard.geojson\nid = geojson\ndisplayName = GeoJSON\nshortname = geojson\n</code></pre>\n<p>The ingest command always returns:</p>\n<pre><code>0 ingested, 1 failed\n</code></pre>\n<p>The DDF admin UI shows:</p>\n<pre><code>"Persistent Storage Not Responding. Could Not Retrieve Alerts."\n</code></pre>\n<p>I only created a single Solr core named "alerts".\nI'm not sure what cores or configsets DDF requires when using external Solr.</p>\n<hr />\n<h2>Question</h2>\n<p>Exactly what Solr cores and configsets does DDF 2.26.45 require when using external Solr, and how do I configure them so that:</p>\n<ol>\n<li>GeoJSON ingestion works</li>\n<li>The Solr error "cannot sort on multivalued field: id_txt" stops</li>\n<li>The internal alerts/persistence store initializes properly</li>\n</ol>\n<p>If anyone has a working external-Solr setup for DDF 2.26.x, please share the required cores, configsets, and schema.xml examples.</p>\n"
}, {
"tags" : [ "java", "mysql", "jdbc" ],
"owner" : {
"account_id" : 33388552,
"reputation" : 21,
"user_id" : 26564077,
"user_type" : "registered",
"profile_image" : "https://www.gravatar.com/avatar/27ad4b2bfc97f8e56a8bb8f9cadc0106?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "PEREZ MONSIVAIS JOSE DE JESUS ",
"link" : "https://stackoverflow.com/users/26564077/perez-monsivais-jose-de-jesus"
},
"is_answered" : false,
"view_count" : 65,
"closed_date" : 1764809796,
"answer_count" : 0,
"score" : 3,
"last_activity_date" : 1764809746,
"creation_date" : 1764806995,
"last_edit_date" : 1764808173,
"question_id" : 79837422,
"link" : "https://stackoverflow.com/questions/79837422/why-dont-my-mysql-usernames-match-when-i-use-them-in-jdbc",
"closed_reason" : "Duplicate",
"title" : "Why don't my MySQL usernames match when I use them in JDBC?",
"body" : "<p>I’m having trouble understanding how MySQL users actually work.<br />\nWhen I run:</p>\n<p><code>SELECT USER();</code> MySql shows: <code>root@localhost</code> .<br />\nBut my username when i log in is <em><strong>ade</strong></em>. so when I to set a connection using <code>DriverManager. getConnnection()</code>, I try both usernames but it gives me:</p>\n<pre><code>Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'ade'@'localhost' (using password: YES)\n at jdbcpractices.Test.main(Test.java:18)\n</code></pre>\n<p>or</p>\n<pre><code>Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root@localhost'@'localhost' (using password: YES)\n at jdbcpractices.Test.main(Test.java:18)\n</code></pre>\n<p>It only works when using the user <code>"root"</code>. (my implementation below.)</p>\n<pre><code>public class Test {\n public static void main(String[] args) {\n String user = "root"; //ade\n String password = "quesadilla";\n String URL = "jdbc:mysql://localhost:3306/ademysql";\n\n try {\n Connection conn = DriverManager.getConnection(URL, user, password);\n System.out.println("Connected to database");\n } catch (SQLException e) {\n throw new RuntimeException(e);\n }\n\n }\n}\n</code></pre>\n<p>So what’s the difference between them? Isn’t it supposed to work with <code>ade</code> or <code>root@localhost</code> as well? I’m confused about how this works underneath. Please give me some guidelines or help me understand this confusion. Thanks in advance!!</p>\n"
}, {
"tags" : [ "java", "spring", "hibernate" ],
"owner" : {
"account_id" : 5178848,
"reputation" : 5,
"user_id" : 4145112,
"user_type" : "registered",
"accept_rate" : 12,
"profile_image" : "https://www.gravatar.com/avatar/85a447bfcf15f47e4764fe2944fe7c91?s=256&d=identicon&r=PG&f=y&so-version=2",
"display_name" : "Removed",
"link" : "https://stackoverflow.com/users/4145112/removed"
},
"is_answered" : false,
"view_count" : 58,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764792298,
"creation_date" : 1764790978,
"last_edit_date" : 1764792298,
"question_id" : 79837267,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79837267/hibernate-lazyinitializationexception-cannot-evaluate-tostring",
"title" : "Hibernate LazyInitializationException - Cannot evaluate .toString()",
"body" : "<p>I'm migrating from Spring Boot 2.7 to Spring Boot 3 and this means i'm migrating from Hibernate 5 to Hibernate 6.</p>\n<p>I'm meeting some LazyInitializationException .</p>\n<p>This is part of a entity of mine:</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Data\n@AllArgsConstructor\n@NoArgsConstructor\n@Entity\n@Table(name = "base_doc_class", schema = "anag")\n@EqualsAndHashCode(callSuper = true)\n@ToString(callSuper = true)\npublic class BaseDocClass extends AuditTrailEntity implements Serializable {\n\n\n\n @EqualsAndHashCode.Exclude\n @ToString.Exclude\n @OneToMany(fetch = FetchType.LAZY, mappedBy = "baseDocClass")\n private Set<UserDocClass> userDocClass;\n\n @ManyToOne\n @JoinColumn(name = "parent_id")\n private BaseDocClass parentClass;\n\n\n}\n</code></pre>\n<p>And this is my other entity:</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Data\n@AllArgsConstructor\n@NoArgsConstructor\n@Entity\n@Table(name = "user_doc_class", schema = "anag")\n@EqualsAndHashCode(callSuper = true)\n@ToString(callSuper = true)\npublic class UserDocClass extends AuditTrailEntity implements Serializable {\n\n\n\n @ManyToOne\n @JsonIgnore\n @JoinColumn(name = "base_doc_class_id")\n private BaseDocClass baseDocClass;\n\n @EqualsAndHashCode.Exclude\n @ToString.Exclude\n @JsonIgnore\n @OneToMany(fetch = FetchType.LAZY, mappedBy = "userDocClass")\n private Set<ArchiveDocclassMimetype> archiveDocclassMimetype;\n\n\n}\n</code></pre>\n<p>Since I passed to Hibernate 6 I'm meeting Hibernate Lazy Exception each time I make a get of an entity from another entity, this is a simple code sample:</p>\n<pre class=\"lang-java prettyprint-override\"><code>pdv.setParentdocclassname(syncPdvBucketHolder.getUserDocClass().getBaseDocClass().getName());\n</code></pre>\n<p>The BaseDocClass contained by the UserDocClass has only the id, the other attributes are empty and when I try to run that code I'm meeting this exception (package name censored):</p>\n<pre class=\"lang-none prettyprint-override\"><code>could not initialize proxy [****.entity.anag.BaseDocClass#22897e28-c859-401a-a19e-82216f64a891] - no Session\n</code></pre>\n<p>I tried most solutions I read online to solve this. I tried adding <code>@ManyToOne(fetch = fetchtype.eager)</code> annotation on attibute columns but it didn't work. I tried even using things like the Spring properties:</p>\n<pre class=\"lang-yaml prettyprint-override\"><code>spring:\n jpa:\n open-in-view: true\n properties:\n hibernate:\n enable_lazy_load_no_trans: true\n</code></pre>\n<p>But it still doesn't work.\nI tried using <code>@Transactional</code> annotation on method and it didn't work.</p>\n<p>Do you have any other ideas?</p>\n<p>Here's the complete stacktrace:</p>\n<pre><code>org.hibernate.LazyInitializationException: could not initialize proxy [****.entity.anag.BaseDocClass#22897e28-c859-401a-a19e-82216f64a891] - no Session\n at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:164)\n at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:309)\n at org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor.intercept(ByteBuddyInterceptor.java:44)\n at org.hibernate.proxy.ProxyConfiguration$InterceptorDispatcher.intercept(ProxyConfiguration.java:95)\n at ****.entity.anag.BaseDocClass$HibernateProxy$uYsjXwmW.getName(Unknown Source)\n at ****.service.generic.GenericPdvService.createPdv(GenericPdvService.java:652)\n at ****.pdvupload.service.PdvDepositService.savePdv(PdvDepositService.java:126)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2570)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2366)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onSubscribe(FluxOnErrorResume.java:74)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2570)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2366)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onSubscribe(FluxOnErrorResume.java:74)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2096)\n at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onComplete(FluxDefaultIfEmpty.java:134)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onComplete(MonoFlatMap.java:189)\n at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onComplete(FluxFilterFuseable.java:171)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2572)\n at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.request(FluxFilterFuseable.java:191)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.request(FluxDefaultIfEmpty.java:98)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onSubscribe(MonoFlatMap.java:291)\n at reactor.core.publisher.Operators$BaseFluxToMonoOperator.onSubscribe(Operators.java:2050)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:87)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:158)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2570)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onSubscribe(MonoFlatMap.java:291)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2570)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onSubscribe(MonoFlatMap.java:291)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2570)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2366)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onSubscribe(FluxOnErrorResume.java:74)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.Mono.subscribe(Mono.java:4576)\n at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:205)\n at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:63)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)\n at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)\n at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:503)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)\n at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2096)\n at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onComplete(FluxDefaultIfEmpty.java:134)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152)\n at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onComplete(FluxFilterFuseable.java:171)\n at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2572)\n at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.request(FluxFilterFuseable.java:191)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)\n at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.request(FluxDefaultIfEmpty.java:98)\n at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2366)\n at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onSubscribe(FluxOnErrorResume.java:74)\n at reactor.core.publisher.Operators$BaseFluxToMonoOperator.onSubscribe(Operators.java:2050)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)\n at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:87)\n at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)\n at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:165)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)\n at reactor.core.publisher.MonoUsingWhen$MonoUsingWhenSubscriber.deferredComplete(MonoUsingWhen.java:268)\n at reactor.core.publisher.FluxUsingWhen$CommitInner.onComplete(FluxUsingWhen.java:532)\n at reactor.core.publisher.Operators.complete(Operators.java:137)\n at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:46)\n at reactor.core.publisher.Mono.subscribe(Mono.java:4576)\n at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.onComplete(FluxUsingWhen.java:389)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:246)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:158)\n at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)\n at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2096)\n at reactor.core.publisher.MonoTakeLastOne$TakeLastOneSubscriber.onComplete(MonoTakeLastOne.java:162)\n at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2230)\n at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onComplete(MonoFlatMapMany.java:261)\n at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)\n at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2230)\n at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:102)\n at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:83)\n at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)\n at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondComplete(MonoFlatMap.java:245)\n at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:305)\n at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180)\n at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:176)\n at com.mongodb.reactivestreams.client.internal.MongoOperationPublisher.lambda$sinkToCallback$33(MongoOperationPublisher.java:524)\n at com.mongodb.reactivestreams.client.internal.OperationExecutorImpl.lambda$execute$9(OperationExecutorImpl.java:126)\n at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)\n at com.mongodb.internal.operation.AsyncOperationHelper.lambda$exceptionTransformingCallback$17(AsyncOperationHelper.java:335)\n at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$1(AsyncCallbackSupplier.java:97)\n at com.mongodb.internal.async.function.RetryingAsyncCallbackSupplier$RetryingCallback.onResult(RetryingAsyncCallbackSupplier.java:123)\n at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)\n at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$1(AsyncCallbackSupplier.java:97)\n at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)\n at com.mongodb.internal.async.function.AsyncCallbackSupplier.lambda$whenComplete$1(AsyncCallbackSupplier.java:97)\n at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeBulkWriteBatchAsync$9(MixedBulkWriteOperation.java:352)\n at com.mongodb.internal.async.function.AsyncCallbackLoop$LoopingCallback.onResult(AsyncCallbackLoop.java:85)\n at com.mongodb.internal.async.function.AsyncCallbackLoop$LoopingCallback.onResult(AsyncCallbackLoop.java:62)\n at com.mongodb.internal.async.function.LoopState.breakAndCompleteIf(LoopState.java:113)\n at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeBulkWriteBatchAsync$8(MixedBulkWriteOperation.java:300)\n at com.mongodb.internal.async.function.AsyncCallbackLoop$LoopingCallback.onResult(AsyncCallbackLoop.java:83)\n at com.mongodb.internal.async.function.AsyncCallbackLoop$LoopingCallback.onResult(AsyncCallbackLoop.java:62)\n at com.mongodb.internal.operation.MixedBulkWriteOperation.lambda$executeBulkWriteBatchAsync$7(MixedBulkWriteOperation.java:322)\n at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)\n at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.lambda$executeAsync$0(DefaultServer.java:249)\n at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)\n at com.mongodb.internal.connection.CommandProtocolImpl.lambda$executeAsync$0(CommandProtocolImpl.java:88)\n at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.lambda$sendAndReceiveAsync$1(DefaultConnectionPool.java:774)\n at com.mongodb.internal.connection.UsageTrackingInternalConnection.lambda$sendAndReceiveAsync$1(UsageTrackingInternalConnection.java:150)\n at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:47)\n at com.mongodb.internal.connection.InternalStreamConnection.lambda$sendCommandMessageAsync$0(InternalStreamConnection.java:532)\n at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback$MessageCallback.onResult(InternalStreamConnection.java:826)\n at com.mongodb.internal.connection.InternalStreamConnection$MessageHeaderCallback$MessageCallback.onResult(InternalStreamConnection.java:789)\n at com.mongodb.internal.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:648)\n at com.mongodb.internal.connection.InternalStreamConnection$3.completed(InternalStreamConnection.java:645)\n at com.mongodb.internal.connection.AsynchronousChannelStream$BasicCompletionHandler.completed(AsynchronousChannelStream.java:245)\n at com.mongodb.internal.connection.AsynchronousChannelStream$BasicCompletionHandler.completed(AsynchronousChannelStream.java:228)\n at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)\n at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:284)\n at java.base/sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ReadTask.completed(WindowsAsynchronousSocketChannelImpl.java:586)\n at java.base/sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:387)\n at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)\n at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)\n at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)\n at java.base/java.lang.Thread.run(Thread.java:842)\n</code></pre>\n"
}, {
"tags" : [ "python", "java" ],
"owner" : {
"account_id" : 44001651,
"reputation" : 9,
"user_id" : 31524773,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/9nPWTXaK.jpg?s=256",
"display_name" : "Amit_45",
"link" : "https://stackoverflow.com/users/31524773/amit-45"
},
"is_answered" : false,
"view_count" : 107,
"closed_date" : 1764777703,
"answer_count" : 0,
"score" : -4,
"last_activity_date" : 1764775940,
"creation_date" : 1764775777,
"last_edit_date" : 1764775940,
"question_id" : 79837052,
"link" : "https://stackoverflow.com/questions/79837052/how-does-garbage-collection-differ-between-python-and-java-and-when-do-objects",
"closed_reason" : "Needs more focus",
"title" : "How does garbage collection differ between Python and Java, and when do objects actually get destroyed?",
"body" : "<p>I'm trying to understand how garbage collection works in Python vs Java.</p>\n<p>From what I know:</p>\n<ul>\n<li><p>Python uses reference counting + a garbage collector</p>\n</li>\n<li><p>Java uses an automatic garbage collector based on JVM</p>\n</li>\n</ul>\n<p>But I'm confused about when objects are actually destroyed in both languages.</p>\n<p>For example:</p>\n<ul>\n<li><p>Python code</p>\n<pre class=\"lang-py prettyprint-override\"><code>class A:\n def __del__(self):\n print("Destroyed")\n\nobj = A()\nobj = None\nprint("End")\n</code></pre>\n<p>Sometimes <code>__del__</code> prints immediately, and sometimes it doesn't (especially when using circular references).</p>\n</li>\n<li><p>Java code</p>\n<pre class=\"lang-java prettyprint-override\"><code>class A {\n protected void finalize() {\n System.out.println("Destroyed");\n }\n}\n\npublic class Main {\n public static void main(String[] args) {\n A obj = new A();\n obj = null;\n System.out.println("End");\n }\n}\n</code></pre>\n<p>In Java, the <code>finalize()</code> method doesn’t always run before the program ends.</p>\n</li>\n</ul>\n<p>My questions:</p>\n<ol>\n<li><p>When exactly does object destruction happen in Python and Java?</p>\n</li>\n<li><p>Is there a way in either language to force object destruction?</p>\n</li>\n<li><p>Why does <code>__del__</code> in Python behave differently in some cases?</p>\n</li>\n</ol>\n"
}, {
"tags" : [ "java", "spring", "mongodb" ],
"owner" : {
"account_id" : 30652349,
"reputation" : 1,
"user_id" : 23498477,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a/ACg8ocJd-a6RfKp4SSYss-LIfbUiMgcvXquxYmtmQxb7bBtSKA=k-s256",
"display_name" : "Investia.tech",
"link" : "https://stackoverflow.com/users/23498477/investia-tech"
},
"is_answered" : false,
"view_count" : 75,
"closed_date" : 1764765941,
"answer_count" : 1,
"score" : -3,
"last_activity_date" : 1764766161,
"creation_date" : 1764765651,
"question_id" : 79836893,
"link" : "https://stackoverflow.com/questions/79836893/spring-boot-4-0-0-with-a-mongodb-database-the-properties-in-application-propert",
"closed_reason" : "Duplicate",
"title" : "Spring Boot 4.0.0 with a MongoDB database, the properties in application.properties are not working",
"body" : "<p>The properties in the <code>application.properties</code> file are not working. The application connects to the <code>test</code> database instead of the one specified in the <code>application.properties</code> file, and it also connects without any credentials credential=null.</p>\n<pre><code>spring.data.mongodb.host=localhost\nspring.data.mongodb.port=27017\nspring.data.mongodb.database=newsletter\nspring.data.mongodb.username=newsletter_user\nspring.data.mongodb.password=secret\nspring.data.mongodb.authentication-database=admin\n</code></pre>\n<p>I also try uri:</p>\n<pre><code>spring.data.mongodb.uri=mongodb://newsletter_user:secret@localhost:27017/newsletter?authSource=admin\n</code></pre>\n<p>Import application.yml</p>\n<pre><code>implementation("org.springframework.boot:spring-boot-starter-data-mongodb")\n</code></pre>\n<p>The temporary workaround I managed to implement is using a configuration <code>@Bean</code>.</p>\n<pre><code>package tech.investia.newsletter.configs;\n\nimport com.mongodb.ConnectionString;\nimport com.mongodb.MongoClientSettings;\nimport com.mongodb.client.MongoClient;\nimport com.mongodb.client.MongoClients;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.data.mongodb.core.MongoTemplate;\n\n@Configuration\npublic class MongoConfig {\n private static final String MONGO_URI =\n "mongodb://newsletter_user:secret@localhost:27017/newsletter?authSource=admin";\n\n @Bean\n public MongoClient mongoClient() {\n ConnectionString cs = new ConnectionString(MONGO_URI);\n\n MongoClientSettings settings = MongoClientSettings.builder()\n .applyConnectionString(cs)\n .build();\n\n return MongoClients.create(settings);\n }\n\n @Bean\n public MongoTemplate mongoTemplate(MongoClient mongoClient) {\n ConnectionString cs = new ConnectionString(MONGO_URI);\n assert cs.getDatabase() != null;\n return new MongoTemplate(mongoClient, cs.getDatabase());\n }\n}\n</code></pre>\n"
}, {
"tags" : [ "java", "android", "kotlin" ],
"owner" : {
"account_id" : 24684693,
"reputation" : 11,
"user_id" : 18578047,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a-/AOh14GiDotuPHOQsBrs67uNg0sc4tYglvtUTw0rO_a2z_g=k-s256",
"display_name" : "Shah Suhail",
"link" : "https://stackoverflow.com/users/18578047/shah-suhail"
},
"is_answered" : false,
"view_count" : 54,
"answer_count" : 2,
"score" : 0,
"last_activity_date" : 1764764290,
"creation_date" : 1764762213,
"last_edit_date" : 1764763686,
"question_id" : 79836830,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836830/how-to-use-callbacks-in-android-kotlin",
"title" : "How to use Callbacks in Android Kotlin",
"body" : "<p>Callbacks in Adapter :- If i having an adapter and there i having a button onto which i want to click and pass that value to the activity inorder to navigate or toast something on the screen.</p>\n"
}, {
"tags" : [ "java", "spring", "hibernate", "jpa", "pgvector" ],
"owner" : {
"account_id" : 44226426,
"reputation" : 21,
"user_id" : 31642875,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/TwsbxWJj.png?s=256",
"display_name" : "Iwan de Jong",
"link" : "https://stackoverflow.com/users/31642875/iwan-de-jong"
},
"is_answered" : true,
"view_count" : 37,
"answer_count" : 1,
"score" : 1,
"last_activity_date" : 1764832132,
"creation_date" : 1764760794,
"last_edit_date" : 1764775937,
"question_id" : 79836804,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836804/hibernate-invalid-stream-header-0-when-trying-to-deserialize-pgvector-embe",
"title" : "Hibernate: Invalid stream header "[-0." when trying to deserialize pgvector embedding into JPA entity",
"body" : "<p>I created a PGvector database:</p>\n<pre class=\"lang-sql prettyprint-override\"><code>CREATE TABLE IF NOT EXISTS vector_store (\n id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,\n content text,\n metadata jsonb,\n embedding vector(1024),\n created_at timestamptz DEFAULT now()\n);\n</code></pre>\n<p>and defined a JPA entity following <a href=\"https://docs.hibernate.org/orm/current/userguide/html_single/#vector-module\" rel=\"nofollow noreferrer\">Hibernate's documentation regarding vectors</a>:</p>\n<pre class=\"lang-java prettyprint-override\"><code>@Entity\n@Table(name = "vector_store")\npublic class Document {\n @Id\n @Column(columnDefinition = "uuid")\n private UUID id;\n\n @Column(columnDefinition = "text")\n private String content;\n\n @JdbcTypeCode(SqlTypes.JSON)\n @Column(columnDefinition = "jsonb")\n private LogMetadata metadata;\n\n @JdbcTypeCode(SqlTypes.VECTOR)\n @Column(columnDefinition = "vector(1024)")\n @Array(length = 1024)\n private double[] embedding;\n\n // getters and setters\n}\n</code></pre>\n<p>However, when trying to deserialize the embedding into a Document object,</p>\n<pre class=\"lang-java prettyprint-override\"><code>public List<Document> fetchAllDocuments() {\n return documentRepository.findAll();\n}\n</code></pre>\n<p>I get the following error:</p>\n<pre><code>org.hibernate.type.SerializationException: could not deserialize\n...\njava.io.StreamCorruptedException: invalid stream header: 5B2D302E\n</code></pre>\n<p>Info: <code>5B2D302E</code> translates to <code>[-0.</code>, which is the first few characters of the embedding of an entry.</p>\n<p>I tried <code>SqlTypes.VECTOR_FLOAT64</code> as well, but without luck.</p>\n<p>Any idea what this could be?</p>\n"
}, {
"tags" : [ "java", "android", "kotlin", "android-studio", "android-studio-3.0" ],
"owner" : {
"account_id" : 19057866,
"reputation" : 1,
"user_id" : 13914597,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/eA0GSyzv.jpg?s=256",
"display_name" : "Ankit Kumar",
"link" : "https://stackoverflow.com/users/13914597/ankit-kumar"
},
"is_answered" : false,
"view_count" : 30,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764744234,
"creation_date" : 1764744234,
"question_id" : 79836589,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836589/cannot-import-place-field-name-lat-lng-address-in-google-places-sdk-5-x",
"title" : "Cannot import Place.Field.NAME, LAT_LNG, ADDRESS in Google Places SDK 5.x",
"body" : "<p>I am using the new Google Places SDK in my Android app.</p>\n<pre><code>places = "5.1.1"\nplaces = { module = "com.google.android.libraries.places:places", version.ref = "places" }\n\n val fields: List<Place.Field> = listOf(\n Place.Field.ID,\n Place.Fie\n\nld.NAME,\n Place.Field.LAT_LNG,\n Place.Field.ADDRESS\n )\n\n val intent = Autocomplete.IntentBuilder(AutocompleteActivityMode.FULLSCREEN, fields)\n .setCountry("IN")\n .build(this)\n</code></pre>\n<p>But the class doesn't contain these fields.</p>\n<p><strong>What is the correct dependency or import for accessing Place.Field in the latest Places SDK?</strong></p>\n"
}, {
"tags" : [ "java", "xstream", "java-module" ],
"owner" : {
"account_id" : 2152669,
"reputation" : 1762,
"user_id" : 1945316,
"user_type" : "registered",
"accept_rate" : 18,
"profile_image" : "https://www.gravatar.com/avatar/aec50f6ea348ca30f5b77d868d038944?s=256&d=identicon&r=PG",
"display_name" : "Thomas",
"link" : "https://stackoverflow.com/users/1945316/thomas"
},
"is_answered" : true,
"view_count" : 68,
"answer_count" : 3,
"score" : 0,
"last_activity_date" : 1764804841,
"creation_date" : 1764710538,
"last_edit_date" : 1764771649,
"question_id" : 79836333,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836333/java-module-system-breaking-serialization-of-standard-library-classes-is-there",
"title" : "Java Module System Breaking Serialization of Standard Library Classes - Is there a better solution than --add-opens?",
"body" : "<h2>Problem</h2>\n<p>When serializing Java standard library classes (like <code>java.awt.Rectangle</code>, <code>Point</code>, <code>Dimension</code>, etc.) using frameworks like XStream, Jackson, or Gson, I'm forced to use <code>--add-opens</code> flags:</p>\n<pre class=\"lang-bash prettyprint-override\"><code>--add-opens java.desktop/java.awt=ALL-UNNAMED\n</code></pre>\n<p>This is required because serialization frameworks need deep reflection access to private fields, but the module system blocks this even though my code properly declares module dependencies:</p>\n<pre class=\"lang-java prettyprint-override\"><code>module my.app {\n requires java.desktop; // Not sufficient for reflection!\n}\n</code></pre>\n<h2>The Core Issue</h2>\n<p><strong>I cannot open another module's packages from my <code>module-info.java</code></strong> - only the owning module can do that. The <code>opens</code> directive only works for your own packages:</p>\n<pre class=\"lang-java prettyprint-override\"><code>module my.app {\n opens my.package to com.thoughtworks.xstream; // ✓ Works for MY packages\n requires java.desktop; // ✗ Doesn't open THEIR packages\n}\n</code></pre>\n<p>This design seems fundamentally broken for legitimate serialization use cases.</p>\n<h2>Why This Matters</h2>\n<ol>\n<li><strong><code>--add-opens</code> is a maintenance nightmare</strong> - Must track all affected modules across JDK versions</li>\n<li><strong>Runtime-only solution</strong> - Can't be declared in code, hard to discover when missing</li>\n<li><strong>Standard library classes aren't exotic</strong> - These are normal, stable public APIs (<code>Rectangle</code>, <code>Color</code>, <code>File</code>, etc.)</li>\n<li><strong>Affects all reflection-based frameworks</strong> - Not just serialization but also ORMs, testing frameworks, etc.</li>\n</ol>\n<h2>Questions</h2>\n<ol>\n<li><p><strong>Is there a comprehensive library providing serialization converters/adapters for common JDK classes?</strong> Specifically looking for XStream converters, but interested in solutions for Jackson/Gson as well.</p>\n</li>\n<li><p><strong>Why doesn't the JDK provide a "serialization-friendly" module</strong> that explicitly opens these stable classes for reflection? Something like <code>java.desktop.reflection</code> that could be optionally required?</p>\n</li>\n<li><p><strong>Are there any proposals or JEPs addressing this friction between modules and reflection?</strong></p>\n</li>\n</ol>\n<h2>What might be a solution?</h2>\n<ul>\n<li><strong>DTOs/wrapper classes</strong> - Too much boilerplate for dozens of JDK classes</li>\n<li><strong>Custom converters</strong> - Works but requires writing converters for every JDK class I serialize</li>\n</ul>\n<h2>Context</h2>\n<ul>\n<li>Using XStream for configuration serialization</li>\n<li>Need to serialize complex object graphs containing AWT geometry classes</li>\n<li>Java 17+, modular application</li>\n</ul>\n"
}, {
"tags" : [ "java", "intellij-idea", "jvm", "aspectj" ],
"owner" : {
"account_id" : 7654025,
"reputation" : 29,
"user_id" : 5801637,
"user_type" : "registered",
"profile_image" : "https://lh4.googleusercontent.com/-rWUPv_kcq8g/AAAAAAAAAAI/AAAAAAAAEEM/2UKft5ugiS8/s256-rj/photo.jpg",
"display_name" : "Klucha",
"link" : "https://stackoverflow.com/users/5801637/klucha"
},
"is_answered" : false,
"view_count" : 42,
"answer_count" : 1,
"score" : 0,
"last_activity_date" : 1764869157,
"creation_date" : 1764710189,
"last_edit_date" : 1764751253,
"question_id" : 79836329,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836329/how-to-define-run-debug-configuration-templates-per-module",
"title" : "How to define Run/Debug configuration templates per module?",
"body" : "<p>Is it achievable in any way, shape or form, to be able to create a JUnit Run/Debug configuration template that has VM argument <code>-javaagent</code> and it being applied to only one of many modules?</p>\n<p>I have multiple modules, and one is called acceptance-tests, and only in this module I am using an AspectJ weaver, thus needing an aspectjweaver -javaagent. In another module there are unit tests, but when running them from the IDE I don't want the VM argument with aspectjweaver -javaagent to propagate to these unit tests, because it only throws errors and nothing else.</p>\n<p>I am using the IntelliJ's "green arrow" runner to run test in various places in various amounts, thus the need for the template, but it is completely unnecessary in other modules.</p>\n<p>If need be, I can implement any other strategy that allows for restricting this VM argument to only one module. I tried attaching it to the currently running JVM, which works, but it is being attached after all classes are loaded so it doesn't weave anything.</p>\n"
}, {
"tags" : [ "java", "spring-boot", "amazon-elasticache", "lettuce", "valkey" ],
"owner" : {
"account_id" : 505659,
"reputation" : 179,
"user_id" : 1648558,
"user_type" : "registered",
"accept_rate" : 0,
"profile_image" : "https://www.gravatar.com/avatar/581b2ccccbdcec340c4d80039ac64383?s=256&d=identicon&r=PG",
"display_name" : "alex",
"link" : "https://stackoverflow.com/users/1648558/alex"
},
"is_answered" : false,
"view_count" : 52,
"answer_count" : 0,
"score" : 0,
"last_activity_date" : 1764825152,
"creation_date" : 1764707004,
"last_edit_date" : 1764713808,
"question_id" : 79836300,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836300/java-springboot-talking-to-elasticache-api-calls-fail-during-ecs-tasks-auto-sc",
"title" : "Java Springboot talking to Elasticache - API calls fail during ecs tasks auto-scaling",
"body" : "<p>Java Springboot application talks to Aws Elasticache using Lettuce client running on ECS.</p>\n<p>Springboot version 3.4.5\nLettuce version 6.8.1.RELEASE\nElasticache Valkey serverless using IAM authentication</p>\n<p>Observed weird behavior during Load test. When ECS tasks auto-scaling kicks off on high load (cpu >50%) during 500rps,</p>\n<ul>\n<li>API latency spikes</li>\n<li>API calls timeout with 504</li>\n<li>elasticache commands fail with connection timeout, command timeout</li>\n<li>Ecs tasks health check fails and tasks get created/killed continuously in a loop for a while</li>\n</ul>\n<p>It takes ~30mins for the tasks to scale up properly, then everything settles down and APIs behave normally.</p>\n<p>Auto-scale policy triggers when:\nCPU utilization >50%\nMemory utilization >50%</p>\n<p>Elasticache config:\nmaxTotal 15\nmaxIdle 8\nminIdle 3\nconnection timeout 3s\ncommand timeout 2s</p>\n<p>What is going wrong here?\nBelow is the elasticache configuration class. Thanks in advance.</p>\n<pre><code>public class ElastiCacheConfig {\n\n@Bean(destroyMethod = "shutdown")\npublic ClientResources clientResources() {\n return DefaultClientResources.builder()\n .ioThreadPoolSize(8)\n .computationThreadPoolSize(8)\n .reconnectDelay(Delay.equalJitter(\n Duration.ofMillis(100),\n Duration.ofSeconds(30),\n 1, TimeUnit.MILLISECONDS))\n .build();\n}\n\n@Bean(destroyMethod = "shutdown")\npublic RedisClient redisClient(ClientResources clientResources) {\n RedisURI redisURI = RedisURI.builder()\n .withHost(host)\n .withPort(6379)\n .withSsl(true)\n .withAuthentication(getCredentials())\n .withTimeout(Duration.ofMillis(3000))\n .build();\n\n RedisClient client = RedisClient.create(clientResources, redisURI);\n client.setOptions(createClientOptions());\n return client;\n}\n\n@Bean\npublic CompletionStage<BoundedAsyncPool<StatefulRedisConnection<String, String>>> cacheAsyncConnectionPool(RedisClient redisClient) {\n RedisURI redisURI = RedisURI.builder()\n .withHost(host)\n .withPort(port)\n .withSsl(true)\n .withAuthentication(getCredentials())\n .withTimeout(Duration.ofMillis(3000))\n .build();\n\n BoundedPoolConfig poolConfig = BoundedPoolConfig.builder()\n .maxTotal(15)\n .maxIdle(8)\n .minIdle(3)\n .testOnAcquire(true)\n .testOnCreate(true)\n .build();\n\n return AsyncConnectionPoolSupport.createBoundedObjectPoolAsync(\n () -> redisClient.connectAsync(StringCodec.UTF8, redisURI),\n poolConfig);\n}\n\nprivate ClientOptions createClientOptions() {\n return ClientOptions.builder()\n .pingBeforeActivateConnection(true)\n .socketOptions(SocketOptions.builder()\n .connectTimeout(Duration.ofMillis(3000))\n .keepAlive(true)\n .tcpNoDelay(true)\n .build())\n .timeoutOptions(TimeoutOptions.builder()\n .fixedTimeout(Duration.ofMillis(2000))\n .build())\n .build();\n}\n\nprivate RedisCredentialsProvider getCredentials() {\n AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();\n IAMAuthTokenRequest iamAuthTokenRequest = new IAMAuthTokenRequest(user, name, region, true);\n return new RedisIAMAuthCredentialsProvider(\n user, iamAuthTokenRequest, awsCredentialsProvider);\n}\n</code></pre>\n<p>}</p>\n"
}, {
"tags" : [ "java", "bash", "runtime" ],
"owner" : {
"account_id" : 30381559,
"reputation" : 33,
"user_id" : 23282541,
"user_type" : "registered",
"profile_image" : "https://lh3.googleusercontent.com/a/ACg8ocI_HWJY9h-eXMR8M5m3pUeJeSo3rK5cnY9VPnOuOe3tkQ=k-s256",
"display_name" : "user23282541",
"link" : "https://stackoverflow.com/users/23282541/user23282541"
},
"is_answered" : true,
"view_count" : 84,
"closed_date" : 1764702287,
"answer_count" : 1,
"score" : -1,
"last_activity_date" : 1764697036,
"creation_date" : 1764694670,
"question_id" : 79836133,
"link" : "https://stackoverflow.com/questions/79836133/how-to-give-root-access-to-java-runtime-process",
"closed_reason" : "Not suitable for this site",
"title" : "How to give root access to Java Runtime Process?",
"body" : "<p>I am trying to run a bash command through Java.Runtime.exec(), specifically coredumpctl.</p>\n<p>I am only able to run the command on a bash terminal when I login as a root user, and this doesn't seem to be the same permission that the Java.Runtime has.</p>\n<p>Is there any way to modify the Java.Runtime login or grant the Runtime root access?</p>\n"
}, {
"tags" : [ "java", "logging", "stream" ],
"owner" : {
"account_id" : 2920132,
"reputation" : 171,
"user_id" : 5325562,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/ZffWS.jpg?s=256",
"display_name" : "Maarten",
"link" : "https://stackoverflow.com/users/5325562/maarten"
},
"is_answered" : true,
"view_count" : 75,
"answer_count" : 2,
"score" : 0,
"last_activity_date" : 1764842239,
"creation_date" : 1764691493,
"last_edit_date" : 1764842239,
"question_id" : 79836078,
"content_license" : "CC BY-SA 4.0",
"link" : "https://stackoverflow.com/questions/79836078/java-stream-api-logging-inside-a-stream",
"title" : "java stream api: logging inside a stream",
"body" : "<p>Disclaimer: The question below was met with quite a bit of critisicm. The only reason I did not delete this question is becasue stackoverflow doesnt let me after somebody reacted on it. Also the code has been altered so lots of the criticism doesnt apply anymore. I did trigger some discussion though. I guess that's good. Maybe this concept will result in an improved new question from me or somebody else. Here it comes:</p>\n<p>I really love the way you can program with java streams as a way to get from an input variable to a output in a series of well defined standardized steps, like map and filter. Therefore it sometimes feel like a pitty to leave this structure. Sometimes it seems easier and more readible to leave this structure, but that might be because a lack of available library functionality, best practices or my knowledge thereof.</p>\n<p>Let's look at this 'old-school' code (well it does have Optional and var so not that old-school)</p>\n<pre><code>public Optional<Address> getValidSupplierAddress(Contact contact) {\n if (!contact.hadRecentProjects) {\n log.debug("contact didn't have any recent projects");\n return Optional.empty();\n }\n if (!contact.validatedByBoardOfCommerce()) {\n log.debug("contact is not validated by board of commerce");\n return Optional.empty();\n }\n var address = contact.getAddress();\n if (address == null) {\n log.debug("no address specified for contact");\n return Optional.empty();\n }\n if (address.isPobox()) {\n log.debug("address is not valid, no po. box allowed");\n return Optional.empty();\n }\n return Optional.of(address);\n}\n</code></pre>\n<p>You could write this into something like this:</p>\n<pre><code>public Optional<Address> getValidSupplierAddress(Contact contact) {\n return Optional.of(contact)\n .filter(testOrElse(Contact::hadRecentProjects, \n () -> log.debug("contact didn't have any recent projects")))\n .filter(testOrElse(Contact::validatedByBoardOfCommerce, \n () -> log.debug("contact is not validated by board of commerce")))\n .map(supplier -> Optional.of(supplier.getAddress())\n .filter(testOrElse(Optional::isPresent, \n () -> log.debug("no address specified for supplier")))\n .map(Optional::get)\n .filter(testOrElse(not(Address::isPobox), \n () -> log.debug("address is not valid, no po. box allowed")));\n}\n\n private <X> Predicate<X> testOrElse(Predicate<X> condition, Runnable executeOnFalse) {\n return condition.or(x1 -> { executeOnFalse.run(); return false; });\n }\n\n</code></pre>\n<p>Did I make more readable code here or not? Not quite sure yet. I But I guess when there are any library functions that would support an approach similar to this, it might become (even?) more readable. Can anybody improve upon this code, preferrably using existing mainstream libraries?</p>\n"
}, {
"tags" : [ "java", "formatting", "classcastexception", "messageformat" ],
"owner" : {
"account_id" : 181683,
"reputation" : 460,
"user_id" : 415848,
"user_type" : "registered",
"profile_image" : "https://i.sstatic.net/CekZ3.jpg?s=256",
"display_name" : "Maarten van Leunen",
"link" : "https://stackoverflow.com/users/415848/maarten-van-leunen"