Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
6d80a97f
Commit
6d80a97f
authored
Dec 01, 2025
by
Luna Riegel
Browse files
Fix: Remove race condition in Schematron thread
parent
3152a987
Changes
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/check/Checker.java
View file @
6d80a97f
...
...
@@ -81,8 +81,6 @@ import java.io.InputStream;
import
java.io.UncheckedIOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.text.ChoiceFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
...
...
@@ -195,26 +193,31 @@ public class Checker {
if
(
config
==
null
)
{
config
=
ValidationConfiguration
.
loadStandardValidationConfig
();
}
Thread
schematronThread
=
new
Thread
(()
->
{
SvrlContentHandler
handler
=
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
if
(
handler
!=
null
)
{
handleSchematronResults
(
handler
);
}
});
schematronThread
.
start
();
Callable
<
SvrlContentHandler
>
schematronThread
=
()
->
executeSchematronValidationIfAvailable
(
config
,
model
.
getFile
());
ExecutorService
executor
=
Executors
.
newSingleThreadExecutor
();
Future
<
SvrlContentHandler
>
handlerFuture
=
executor
.
submit
(
schematronThread
);
executor
.
shutdown
();
checkCityModel
(
model
,
l
);
if
(
schematronThread
.
isAlive
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.schematronStillRunning"
));
if
(!
handlerFuture
.
isDone
())
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
Localization
.
getText
(
"Checker.schematronStillRunning"
));
}
if
(
l
!=
null
){
l
.
updateProgress
(-
0.5f
);
}
try
{
schematronThread
.
join
();
logger
.
info
(
Localization
.
getText
(
"Checker.schematronCompleted"
));
}
catch
(
InterruptedException
e
)
{
logger
.
error
(
Localization
.
getText
(
"Checker.schematronInterrupted"
),
e
);
schematronThread
.
interrupt
();
}
try
{
SvrlContentHandler
handler
=
handlerFuture
.
get
();
if
(
handler
!=
null
)
{
handleSchematronResults
(
handler
);
}
}
catch
(
ExecutionException
e
)
{
logger
.
error
(
e
);
}
catch
(
InterruptedException
e
)
{
logger
.
error
(
Localization
.
getText
(
"Checker.schematronInterrupted"
),
e
);
Thread
.
currentThread
().
interrupt
();
}
CacheManager
.
synchronizeCache
();
model
.
setValidated
(
createValidationPlan
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment