|
1 | 1 | /*
|
2 | 2 | *
|
3 | 3 | * *
|
| 4 | + * * * Copyright 2019-2020 the original author or authors. |
4 | 5 | * * *
|
5 |
| - * * * * Copyright 2019-2022 the original author or authors. |
6 |
| - * * * * |
7 |
| - * * * * Licensed under the Apache License, Version 2.0 (the "License"); |
8 |
| - * * * * you may not use this file except in compliance with the License. |
9 |
| - * * * * You may obtain a copy of the License at |
10 |
| - * * * * |
11 |
| - * * * * https://www.apache.org/licenses/LICENSE-2.0 |
12 |
| - * * * * |
13 |
| - * * * * Unless required by applicable law or agreed to in writing, software |
14 |
| - * * * * distributed under the License is distributed on an "AS IS" BASIS, |
15 |
| - * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 |
| - * * * * See the License for the specific language governing permissions and |
17 |
| - * * * * limitations under the License. |
| 6 | + * * * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * * * you may not use this file except in compliance with the License. |
| 8 | + * * * You may obtain a copy of the License at |
18 | 9 | * * *
|
| 10 | + * * * https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * * * |
| 12 | + * * * Unless required by applicable law or agreed to in writing, software |
| 13 | + * * * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * * * See the License for the specific language governing permissions and |
| 16 | + * * * limitations under the License. |
19 | 17 | * *
|
20 | 18 | *
|
21 | 19 | */
|
|
33 | 31 | import org.apache.commons.lang3.ArrayUtils;
|
34 | 32 |
|
35 | 33 | import org.springframework.core.annotation.AnnotatedElementUtils;
|
| 34 | +import org.springframework.util.CollectionUtils; |
36 | 35 | import org.springframework.web.bind.annotation.DeleteMapping;
|
37 | 36 | import org.springframework.web.bind.annotation.GetMapping;
|
38 | 37 | import org.springframework.web.bind.annotation.PostMapping;
|
@@ -271,21 +270,26 @@ else if (reqMappingClass != null) {
|
271 | 270 | * @param headers the headers
|
272 | 271 | */
|
273 | 272 | private void fillMethods(String[] produces, String[] consumes, String[] headers) {
|
274 |
| - if (ArrayUtils.isNotEmpty(produces)) |
275 |
| - methodProduces = produces; |
276 |
| - else if (ArrayUtils.isNotEmpty(classProduces)) |
277 |
| - methodProduces = classProduces; |
278 |
| - else |
279 |
| - methodProduces = new String[] { defaultProducesMediaType }; |
| 273 | + if (ArrayUtils.isEmpty(methodProduces)) { |
| 274 | + if (ArrayUtils.isNotEmpty(produces)) |
| 275 | + methodProduces = produces; |
| 276 | + else if (ArrayUtils.isNotEmpty(classProduces)) |
| 277 | + methodProduces = classProduces; |
| 278 | + else |
| 279 | + methodProduces = new String[] { defaultProducesMediaType }; |
| 280 | + } |
280 | 281 |
|
281 |
| - if (ArrayUtils.isNotEmpty(consumes)) |
282 |
| - methodConsumes = consumes; |
283 |
| - else if (ArrayUtils.isNotEmpty(classConsumes)) |
284 |
| - methodConsumes = classConsumes; |
285 |
| - else |
286 |
| - methodConsumes = new String[] { defaultConsumesMediaType }; |
| 282 | + if (ArrayUtils.isEmpty(methodConsumes)) { |
| 283 | + if (ArrayUtils.isNotEmpty(consumes)) |
| 284 | + methodConsumes = consumes; |
| 285 | + else if (ArrayUtils.isNotEmpty(classConsumes)) |
| 286 | + methodConsumes = classConsumes; |
| 287 | + else |
| 288 | + methodConsumes = new String[] { defaultConsumesMediaType }; |
| 289 | + } |
287 | 290 |
|
288 |
| - setHeaders(headers); |
| 291 | + if (CollectionUtils.isEmpty(this.headers)) |
| 292 | + setHeaders(headers); |
289 | 293 | }
|
290 | 294 |
|
291 | 295 | /**
|
|
0 commit comments