Skip to content

Commit 3918233

Browse files
authored
fix: prevent intermittent proxy file missing errors in EcotoneLite tests (#648)
* fix: prevent intermittent proxy file missing errors in EcotoneLite tests * fix: remove unnecessary clearstatcache call
1 parent 9796628 commit 3918233

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/Ecotone/src/Messaging/Handler/Gateway/ProxyFactory.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ private function loadProxyClass(GatewayProxyReference $proxyReference): string
6565
{
6666
if (! self::isLoaded($proxyReference)) {
6767
$file = $this->generateCachedProxyFileFor($proxyReference, ! $this->serviceCacheConfiguration->shouldUseCache());
68+
if (! file_exists($file)) {
69+
$file = $this->generateCachedProxyFileFor($proxyReference, true);
70+
}
6871
require $file;
6972
}
7073

@@ -116,8 +119,13 @@ private function dumpFile(string $fileName, string $code): void
116119

117120
$tmpFileName = $fileName . '.' . bin2hex(random_bytes(12));
118121

119-
file_put_contents($tmpFileName, $code);
122+
if (file_put_contents($tmpFileName, $code) === false) {
123+
throw ConfigurationException::create("Failed to write proxy cache file {$tmpFileName}");
124+
}
120125
@chmod($tmpFileName, 0664);
121-
rename($tmpFileName, $fileName);
126+
if (rename($tmpFileName, $fileName) === false) {
127+
@unlink($tmpFileName);
128+
throw ConfigurationException::create("Failed to rename proxy cache file from {$tmpFileName} to {$fileName}");
129+
}
122130
}
123131
}

0 commit comments

Comments
 (0)