diff --git a/packages/Ecotone/src/Messaging/Handler/Gateway/ProxyFactory.php b/packages/Ecotone/src/Messaging/Handler/Gateway/ProxyFactory.php index fe95d3ddc..1189c4868 100644 --- a/packages/Ecotone/src/Messaging/Handler/Gateway/ProxyFactory.php +++ b/packages/Ecotone/src/Messaging/Handler/Gateway/ProxyFactory.php @@ -65,6 +65,9 @@ private function loadProxyClass(GatewayProxyReference $proxyReference): string { if (! self::isLoaded($proxyReference)) { $file = $this->generateCachedProxyFileFor($proxyReference, ! $this->serviceCacheConfiguration->shouldUseCache()); + if (! file_exists($file)) { + $file = $this->generateCachedProxyFileFor($proxyReference, true); + } require $file; } @@ -116,8 +119,13 @@ private function dumpFile(string $fileName, string $code): void $tmpFileName = $fileName . '.' . bin2hex(random_bytes(12)); - file_put_contents($tmpFileName, $code); + if (file_put_contents($tmpFileName, $code) === false) { + throw ConfigurationException::create("Failed to write proxy cache file {$tmpFileName}"); + } @chmod($tmpFileName, 0664); - rename($tmpFileName, $fileName); + if (rename($tmpFileName, $fileName) === false) { + @unlink($tmpFileName); + throw ConfigurationException::create("Failed to rename proxy cache file from {$tmpFileName} to {$fileName}"); + } } }