Skip to content

Commit

Permalink
JENKINS-54128 remove call to deprecated Run.getLogFile
Browse files Browse the repository at this point in the history
  • Loading branch information
mguillem committed Aug 17, 2021
1 parent 7b6819d commit d740bc3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/*
* The MIT License
*
* Copyright (c) 20import hudson.MarkupText;
import hudson.console.ConsoleAnnotator;
import hudson.model.Run;
import java.text.MessageFormat;
d associated documentation files (the "Software"), to deal
*
* Copyright (c) 2014, Vincent Latombe
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -31,7 +29,7 @@ d associated documentation files (the "Software"), to deal

import java.text.MessageFormat;

public class LineNumbersAnnotator extends ConsoleAnnotator<Object> {
public class LineNumbersAnnotator extends ConsoleAnnotator<Run<?, ?>> {

private int calls = 0;

Expand All @@ -44,14 +42,11 @@ public LineNumbersAnnotator(long offset) {
}

@Override
public ConsoleAnnotator annotate(Object context, MarkupText text) {
if (!(context instanceof Run)) {
return this;
}
Run r = (Run)context;
long start;
public ConsoleAnnotator<Run<?, ?>> annotate(Run<?, ?> r, MarkupText text) {

final long start;
if (offset < 0) {
start = r.getLogFile().length() + offset;
start = r.getLogText().length() + offset;
} else {
start = offset;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2014, Vincent Latombe
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -26,20 +26,21 @@
import hudson.Extension;
import hudson.console.ConsoleAnnotator;
import hudson.console.ConsoleAnnotatorFactory;
import hudson.model.Run;

import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;

/**
* Adds line numbers to the console logs as well as bookmarkable anchors
*
*
* @author vlatombe
*
*
*/
@Extension(ordinal = -100)
public class LineNumbersAnnotatorFactory extends ConsoleAnnotatorFactory<Object> {
public class LineNumbersAnnotatorFactory extends ConsoleAnnotatorFactory<Run<?, ?>> {
@Override
public ConsoleAnnotator<Object> newInstance(Object context) {
public ConsoleAnnotator<Run<?, ?>> newInstance(Run<?, ?> context) {
long offset = getOffset(Stapler.getCurrentRequest());
return new LineNumbersAnnotator(offset);
}
Expand All @@ -49,7 +50,7 @@ public ConsoleAnnotator<Object> newInstance(Object context) {
* is from the start of the file, and a negative offset is back from the end
* of the file.
* Note : Copied from hudson.plugins.timestamper.annotator.TimestampAnnotatorFactory
*
*
* @param request
* @return the offset in bytes
*/
Expand Down

0 comments on commit d740bc3

Please sign in to comment.