Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void write(XmlWriterRequest<PluginDescriptor> request) throws XmlWriterEx
new PluginDescriptorStaxWriter().write(outputStream, content);
} else {
try (OutputStream os = Files.newOutputStream(path)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore or use: Variable 'os' is never used

  • image
  • image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a critical bug and easy to prevent: https://checkstyle.sourceforge.io/checks/coding/unusedlocalvariable.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug for bug:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wanna try adding the rule check to the PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a bug in checkstyle we already have this checker in place:

@romani

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of checkstyle is in use?
Please share link to config also

Copy link
Contributor Author

@Pankraz76 Pankraz76 May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please share link to config also

config is mystery ATM as it comes from cloud.

Will update, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congo is inherited from parent, but there is a way to override it and complement with the rules needed. You need to analyze how check style is configured in the parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this bug reproducible and tested already in

So its nice to have this info, but not mandatory anymore.

new PluginDescriptorStaxWriter().write(outputStream, content);
new PluginDescriptorStaxWriter().write(os, content);
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor Author

@Pankraz76 Pankraz76 May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.impl;

import java.nio.file.Files;
import java.nio.file.Path;

import org.apache.maven.api.plugin.descriptor.PluginDescriptor;
import org.apache.maven.api.services.xml.XmlWriterRequest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import static org.assertj.core.api.Assertions.assertThat;

class DefaultPluginXmlFactoryReadWriteTest {

private final DefaultPluginXmlFactory defaultPluginXmlFactory = new DefaultPluginXmlFactory();

@TempDir
Path tempDir;

@Test
void writeToPathGeneratesValidXmlFile() throws Exception {
Path xmlFile = tempDir.resolve("output-plugin.xml");
defaultPluginXmlFactory.write(XmlWriterRequest.<PluginDescriptor>builder()
.path(xmlFile)
.content(PluginDescriptor.newBuilder().name("Sample Plugin").build())
.build());
assertThat(Files.readString(xmlFile)).contains("<name>Sample Plugin</name>");
}
}