File tree 2 files changed +14
-11
lines changed
src/Symfony/Component/Messenger
Tests/Transport/Enhancers
2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,10 @@ public function testReceiverLogsMemoryExceededWhenLoggerIsGiven()
101
101
102
102
$ logger = $ this ->createMock (LoggerInterface::class);
103
103
$ logger ->expects ($ this ->once ())->method ('info ' )
104
- ->with ($ this ->equalTo ('Receiver stopped due to memory limit exceeded. ' ));
104
+ ->with (
105
+ $ this ->equalTo ('Receiver stopped due to memory limit of {limit} exceeded ' ),
106
+ $ this ->equalTo (array ('limit ' => 64 * 1024 * 1024 ))
107
+ );
105
108
106
109
$ memoryResolver = function () {
107
110
return 70 * 1024 * 1024 ;
Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ public function receive(callable $handler): void
46
46
$ memoryResolver = $ this ->memoryResolver ;
47
47
if ($ memoryResolver () >= $ this ->memoryLimit ) {
48
48
$ this ->stop ();
49
- if ($ this ->logger ) {
50
- $ this ->logger ->info ('Receiver stopped due to memory limit exceeded. ' );
49
+ if (null !== $ this ->logger ) {
50
+ $ this ->logger ->info ('Receiver stopped due to memory limit of {limit} exceeded ' , array ( ' limit ' => $ this -> memoryLimit ) );
51
51
}
52
52
}
53
53
});
@@ -62,14 +62,14 @@ private function convertToOctets(string $size): int
62
62
{
63
63
if (!\preg_match ('/^(\d+)([G|M|K]*)$/ ' , $ size , $ matches )) {
64
64
throw new \InvalidArgumentException ('Invalid memory limit given. ' );
65
- } else {
66
- if ( ' G ' == $ matches [ 2 ]) {
67
- $ size = $ matches [1 ] * 1024 * 1024 * 1024 ;
68
- } elseif ( ' M ' == $ matches [2 ]) {
69
- $ size = $ matches [1 ] * 1024 * 1024 ;
70
- } elseif ( ' K ' == $ matches [2 ]) {
71
- $ size = $ matches [1 ] * 1024 ;
72
- }
65
+ }
66
+
67
+ if ( ' G ' == $ matches [2 ]) {
68
+ $ size = $ matches [1 ] * 1024 * 1024 * 1024 ;
69
+ } elseif ( ' M ' == $ matches [2 ]) {
70
+ $ size = $ matches [1 ] * 1024 * 1024 ;
71
+ } elseif ( ' K ' == $ matches [2 ]) {
72
+ $ size = $ matches [ 1 ] * 1024 ;
73
73
}
74
74
75
75
return $ size ;
You can’t perform that action at this time.
0 commit comments