Fixed collect more than once time when using watcher. (#2242)

This commit is contained in:
李铭昕 2020-08-05 11:13:01 +08:00 committed by GitHub
parent 50cd5ebfe6
commit 1bd2446a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 1 deletions

View File

@ -3,6 +3,7 @@
## Fixed
- [#2236](https://github.com/hyperf/hyperf/pull/2236) Fixed bug that select node failed when using `loadBalancer` for nacos.
- [#2242](https://github.com/hyperf/hyperf/pull/2242) Fixed bug that collect more than once time when using watcher.
# v2.0.5 - 2020-08-03

View File

@ -66,7 +66,7 @@
"overtrue/flysystem-qiniu": "^1.0",
"php-amqplib/php-amqplib": "^2.7",
"php-di/php-di": "^6.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "0.12.34",
"phpunit/phpunit": "^7.0.0",
"predis/predis": "^1.1",
"reactivex/rxphp": "^2.0",

View File

@ -29,6 +29,19 @@ class SocketIORouter extends MetadataCollector
static::set('backward.' . $className, $nsp);
}
public static function clear(string $key = null): void
{
if ($key !== null) {
parent::clear('backward.' . $key);
foreach (static::$container['forward'] ?? [] as $nsp => $value) {
if ($value == $key) {
unset(static::$container['forward'][$nsp]);
}
}
}
parent::clear($key);
}
public static function getNamespace(string $className)
{
return static::get('backward.' . $className, '/');

View File

@ -94,6 +94,9 @@ class Process
// Collect the annotations.
$ref = $this->reflection->classReflector()->reflect($class);
BetterReflectionManager::reflectClass($class, $ref);
foreach ($collectors as $collector) {
$collector::clear($class);
}
$this->collect($class, $ref);
$collectors = $this->config->getCollectors();